PHP/WordPress 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.
- The topic ‘PHP/WordPress API Codex: How do I hide HTML based on user role?’ is closed to new replies.