Function checking access

Author
Topic
#2521

Hi,

Prompt me in the plugin is a function which is implemented by checking access eg like this “is_user_logged_in”, I would like to implement a loading the special template page for entering purchase code

Alexander

Viewing 15 replies - 1 through 15 (of 15 total)
Author
Replies
  • #2523

    Check out the documentation, it describes all template files and they use. You need file ‘nverify-protected-access.php’, it displays the form for entering purchase code. But, do not change important, form related stuff, or the plugin will not be able to work.

  • #2526

    Hi,

    I mean that on page was only the form for enter the purchase code like as “snapshot2″ [attachment file=”snapshot2.png”] and not like “snapshot1″ [attachment file=”snapshot1.png”]

    Alexander

  • #2530

    You can’t do that because bbPress will not allow it. My plugin adds template to extend bbPress, but it is not changing the way bbPress renders page, only replaces [u]content[/u] for that page. If normal bbPress page contains sidebars and header and everything else, page that shows restricted access shows that also but replacing normal bbPress content part with restricted one, it is not part of the template my plugin can change.

  • #2533

    I understand that your plugin uses the bbpress contents template, so I gave as an example the boolean function analogy “is_user_logged_in()”

    maybe like this:

    if ( is_user_access_forum() ) {
    echo show header content;
    echo show secondary content;
    echo show footer content;
    } else {
    echo ”;
    }

    eg i used

    if ( is_user_logged_in() ) :

    do_action( ‘footer_content’ );

    endif;

  • #2535

    You can’t do that, template my plugin overrides in bbPress can’t contain header/footer/sidebar, it is only for content.

  • #2541

    Hi,

    I looked up and found in plug-in code that implements the function of what I mean, [b]function “check”[/b] in [b]”core/bbpress.php”[/b], as I understand it is implemented by means of checking [b]$user_id = get_current_user_id [];[/b] checking current user has access to the forum or not and also skips checking for administrators and moderators – I understand this correctly?

    Alexander

  • #2542

    Yes, but you can’t just use it anywhere. This is internal function tied into different things, and calling it from random places will not work. bbPress integration has to follow proper procedure if you want to have everything working as intended.

    Milan

  • #2543

    Why is that? For example here this works:

    function is_current_user_skip_protect( $type, $forum_id = 0 ) {
    global $sbv_core_bbpress;
    $sbv_bbpress = new sbv_bbpress();
    $user_id = get_current_user_id();
    $skip = sbv_is_current_user_with_role( $sbv_bbpress->get( ‘access_unrestriced_user_roles’ ) );
    $skip = apply_filters( ‘sbv_skip_protect_check_’ . $type, $skip, $user_id );
    if ( ! $skip ) {
    return true;
    } else {
    return false;
    }
    }

    and

    if ( ! is_current_user_skip_protect( $user_id ) ) {
    get_template_part( ‘templates/secondary/secondary’, ‘bbp’ );
    }

  • #2544

    As I understand it uses envato api and checks from the forum database a users data – I think it should work anywhere! Especially I did not replace the plugin files on the other files – I just want to get through your plugin checks the current user’s access rights to the forum ( true or false ), and on this basis to exclude or include the template parts (header, sidebar, footer)

  • #2545

    Again, my plugin hooks into bbPress, it can’t control how the bbPress is displaying page, it can only replace the content of the current template part. Checks and everything else are hooks into bbPress filters and actions that happen when the page is already forming, it can’t replace rendering of the whole page. My plugin offers different ways to replace elements that can be hidden, and it can’t replace theme template that forms the page (this is what you need infact). For that I would need to override the whole templates, and templates are theme dependent. My plugin works only with parts displayed by bbPress, and nothing else, everything else on the page is displayed by the theme not bbPress.

  • #2546

    I can prepare a standalone function that can return true/false for a current user and a forum, but it can’t do anything else, and you would need to write your own handling to load templates and every thing else. That doesn’t exists right now, because no one asked before because it would be too much work to handle outside of the plugin, and since it will deal with theme templates I will not be able to assist in any way.

    Now, I have on the list for the next version of the plugin to include such function.

  • #2547

    Yes, and for correct work plugin I use the following construction [b]function_exists [‘is_bbpress’] && bbp_is_single_forum [][/b] and that is works only in site section where the forum is

    anyway this working for me correctly

    if ( ! is_current_user_skip_protect( $user_id ) ) {
    get_template_part( ‘templates/secondary/secondary’, ‘bbp’ );
    }

  • #2548

    I would be very grateful to you to help with such a function that checks the access rights for the user and skip user with role administrator and moderator

    Thanks

  • #2549

    I have this on the list for 3.1 version, that should be out in about 7-10 days.

  • #2550

    Thanks, I’ll look forward to

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Function checking access’ is closed to new replies.