Title: User access in PHP templates
Last modified: October 26, 2017

---

# User access in PHP templates

 *  Resolved [YannickPian](https://wordpress.org/support/users/yannickpian/)
 * (@yannickpian)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/user-access-in-php-templates/)
 * 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](https://wordpress.org/support/users/intoxstudio/)
 * (@intoxstudio)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/user-access-in-php-templates/#post-9624984)
 * 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.

 * ![](https://ps.w.org/restrict-user-access/assets/icon-256x256.png?rev=1815922)
 * [Restrict User Access - Ultimate Membership & Content Protection](https://wordpress.org/plugins/restrict-user-access/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/restrict-user-access/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/restrict-user-access/)
 * [Active Topics](https://wordpress.org/support/plugin/restrict-user-access/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/restrict-user-access/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/restrict-user-access/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Joachim Jensen](https://wordpress.org/support/users/intoxstudio/)
 * Last activity: [8 years, 7 months ago](https://wordpress.org/support/topic/user-access-in-php-templates/#post-9624984)
 * Status: resolved