Title: PHP/WordPress API Codex: How do I hide HTML based on user role?
Last modified: August 20, 2016

---

# PHP/WordPress API Codex: How do I hide HTML based on user role?

 *  Resolved [s.fox](https://wordpress.org/support/users/saahirfoux/)
 * (@saahirfoux)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/phpwordpress-api-codex-how-do-i-hide-html-based-on-user-role/)
 * I have a plugin on a client’s site that has more functionality than they will
   ever need. I need to edit it routinely, but should my client poke around they
   could ruin the operations of their site.
 * The plugin has a menu item/page called settings. In settings there are 3 tabs.
   Two of them I need to hide from them.
 * I’d like to hide them based on the role of the current user. So, for example,
   only me, the super admin, will be able to even see those two tabs.
 * Ideally this will be done after a quick edit to the plugin’s files. I’m thinking
   I just need to surround the HTML that produces these tabs with an if statement
   that checks the user role. I just need to know what.
 * So far my research has led me to current_user_can();
 * But it looks like it’s meant for permissions rather than an actual role.
 * I believe I need to do something like this:
 * if ( current_user_can( ‘Super_Admin’ ) ) {
    HTML }
 * Please help in any way you can. I would greatly appreciate it.
 * Thank you.

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [catacaustic](https://wordpress.org/support/users/catacaustic/)
 * (@catacaustic)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/phpwordpress-api-codex-how-do-i-hide-html-based-on-user-role/#post-3531787)
 * You are right, that function does work on permissions and not roles. That’s because
   permissions are.. well permissions!
 * You need ot figure out what [capability](http://codex.wordpress.org/Roles_and_Capabilities#Additional_Admin_Capabilities)
   you want for that area. There’s a wide range there, and and you can see there’s
   a lot that are admin-only. Choose an administrator-only capability and set your
   client up as an editor.
 * You can also set up your own roles and capabilities, but this is probably not
   needed for something like this.
 *  Thread Starter [s.fox](https://wordpress.org/support/users/saahirfoux/)
 * (@saahirfoux)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/phpwordpress-api-codex-how-do-i-hide-html-based-on-user-role/#post-3531846)
 * Thank you, Catacaustic. Your response was very helpful. I will be attempting 
   to implement this pseudo code. Any capability exclusive to the super admin is
   likely what I’ll use.
 * Again I’ll be editing the plugin I’m using directly. I don’t really like doing
   this though, because if the plugin were to be updated I’d have to re-do my changes.
 * Like child-themes, is there a way to safely edit a plugin without worry of having
   your code overwritten by an update?
 *  [catacaustic](https://wordpress.org/support/users/catacaustic/)
 * (@catacaustic)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/phpwordpress-api-codex-how-do-i-hide-html-based-on-user-role/#post-3531861)
 * I’d suggest not doing the super-admin thing. Mainly because super-admins are 
   really only set in a multi-site environment. In a standard installation the highest
   is “Administrator”.
 *  [voala](https://wordpress.org/support/users/voala/)
 * (@voala)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/phpwordpress-api-codex-how-do-i-hide-html-based-on-user-role/#post-3531862)
 * have a look at this: [http://wordpress.org/extend/plugins/adminimize/](http://wordpress.org/extend/plugins/adminimize/)
   
   If needed you could always create a new user role for your customer and hide 
   the buttons from him.
 * Some other problem I encountered with my customers is that they go and try to
   edit theme files from editor in the back end. This always messes the theme files
   up adding blank rows. You can disable this to from the config.php
 *  Thread Starter [s.fox](https://wordpress.org/support/users/saahirfoux/)
 * (@saahirfoux)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/phpwordpress-api-codex-how-do-i-hide-html-based-on-user-role/#post-3531899)
 * Again, thank you for the help. I forgot to mention, I am using a multi-site environment.
   I’ll open another topic for my other question soon.
 * Thanks.
 *  [voala](https://wordpress.org/support/users/voala/)
 * (@voala)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/phpwordpress-api-codex-how-do-i-hide-html-based-on-user-role/#post-3531900)
 * I think it will work with MU to. Try it.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘PHP/WordPress API Codex: How do I hide HTML based on user role?’ is closed
to new replies.

## Tags

 * [current_user_can](https://wordpress.org/support/topic-tag/current_user_can/)
 * [hiding](https://wordpress.org/support/topic-tag/hiding/)
 * [html](https://wordpress.org/support/topic-tag/html/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [role](https://wordpress.org/support/topic-tag/role/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 6 replies
 * 3 participants
 * Last reply from: [voala](https://wordpress.org/support/users/voala/)
 * Last activity: [13 years, 2 months ago](https://wordpress.org/support/topic/phpwordpress-api-codex-how-do-i-hide-html-based-on-user-role/#post-3531900)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
