• Resolved YannickPian

    (@yannickpian)


    Hi,

    I’m trying to use the Restric User Access plugin to restrict some content in my php templates.

    With regular user roles I use:
    <?php //LIMIT ACCESS
    if ( (is_user_logged_in() && current_user_can( ‘contributor’ )) || (is_user_logged_in() && current_user_can( ‘administrator’ )) ){ ?>
    <?php endif; ?>

    How can I use a similar way to filter user.

    Basically I’d like to be able to hide some content (a button). How can I get the current user access level?

    Thank you very much in advance,

    Best
    Yannick

Viewing 1 replies (of 1 total)
  • Plugin Author Joachim Jensen

    (@intoxstudio)

    You should be able to do it like this:

    $level_id = rua_get_level_by_name('level-name');
    if(rua_has_user_level(get_current_user_id(),$level_id)) {
       //restricted content
    }

    If you already know the ID, then you can of course hardcode that instead ?? You can also use a shortcode in your content:

    [restrict level="level-name"]restricted content[/restrict]

    Let me know if this answers your question!

Viewing 1 replies (of 1 total)
  • The topic ‘User access in PHP templates’ is closed to new replies.