You can see here a list of roles and capabilities, if you want to check if the user has a certain role, you can:
$the_user = wp_get_current_user();//we get the current user
if ( in_array( 'the_name_of_your_role', (array) $the_user->roles ) ) {
//the user has the rol, add the submenu here
}
you can use current_user_can if you want to check if the user has a specific capability, like this:
if( current_user_can( 'publish_pages' ) ){
//the user has the capability do something here
}
Related Posts:
- Remove update nags for non-admins [duplicate]
- Allow Editors to edit pending posts but not draft ones
- wp_insert_user role not working
- How to target with css, admin elements according to user role level?
- Remove admin bar for subscribers
- Editor role cannot save custom theme options
- wordpress separate registration for different roles
- Display user role Name – not slug
- Add user settings to specific roles
- How to display conditional-content if wp_nav_menu( $args ) retruns something
- How to give new users two specific user role options upon WordPress user registration
- Hiding div based on user role
- custom user role wordpress – grant guest access to edit.php without insert/update/delete
- How to target grandchild of post_parent using wp_list_pages
- Do not execute If User is login as Administrator or any Specific Role
- WordPress Quick Question . How to Get Parent Link in Submenu in My Code
- get_the_title() gets printed out twice
- Add post with approval by the admin
- How to keep the capability of users and disable Gutenberg editor in WordPress?
- Shortcode for Listing Users from Meta Value?
- Array to string conversion error in PHP 7.2 when returning user role as class
- Noindex subscriber author page
- How to use wp_nav_menu to create custom dropdown menu?
- Query for user roles
- Show login greeting above sub-menu links?
- Remove submenu item from list
- How can I call a specific file (via php) by referencing the logged-in username?
- Plugin: Front-end Editor – User role specific editable content?
- Execute PHP code only with specific user role
- Edit and delete permissions pages and posts
- How to Add a cutsom slug to my custom author role
- Execute function only for specific user roles
- Allow a user or role to view drafts and previews, but not other admin privileges?
- how to create a user rule that can only manage support tickets?
- Hide payment method based on user role AND minimum cart value
- Edit a function to take different actions based on user role
- Used a code to revoke some dashboard menus for my contributors but for some reason it’s revoked me access to the editor [closed]
- Get Child of Child Pages in custom Menu
- How to give custom roles the capability to edit one Menu instead of every Menu
- Add another role to a user when they click a button?
- Obtain wordpress user role
- How to properly create multiple conditions to redirect users roles to different pages
- Echo Option Value Based On WordPress User Role
- Display specific main Sub Nav on Woocommerce product pages
- Beyond widget side menu editing, with the php page, custom template
- Allow BBPress participant role to trash topics
- Custom user roles doesn’t apply changes
- How I can add div to menu?
- wp_nav_menu prints children with parent name
- Include administrator in author list
- How to connect database table to each registered wordpress user.
- Get author meta of all writers
- Can’t remove menu items added by plugin
- Submenu opened problem
- Switch-Case and user_role
- Forbid certain users to access a specific page
- How to lock users account until approvation
- How to create a User Role and give permission to only use Web Stories plugin?
- How to create custom user role without plugin?
- Custom Admin Menu Report for Specific User ID
- How to add custom user role into wordpress
- WordPress Create New Role Just to Manage Users?
- child category under correct parent
- Hide ID for WordPress User Role Subscriber
- How to display all submenu items as a breadcrumb
- How to make widget title accept php?
- Is the wp_enqueue method efficient?
- Filtering a Database Query
- Custom PHP App with a wordpress site
- Royalty-Free Sliders used in theme development
- How can I open up my administrative panel to everyone?
- Change page title from page using php via php executed from page/post itself
- Download images from media library to computer in BULK?
- Define specific category name in PHP
- Can I get an email notification when media is uploaded to the media library?
- PHP Syntax Error on get_posts
- Showing latest post without 301 redirect
- Trying do build a contact form
- Make Current/Active Page Number a Link (WP_LINK_PAGES)
- Convert WordPress date format to jQuery UI Datepicker format
- How to show number of unpublished articles?
- How to make modifications only to certain elements of an HTML string on the server-side?
- “operation successful” message
- WordPress wp_redirect error
- Three Questions with Twenty Eleven theme
- PHP echo inside javascript
- single.php error
- WordPress Theme Modification Help
- Value prints outside of the echo
- RTL Stylesheet Confusion with WordPress
- PHP nested If statement syntax
- WP Insert Post and then go to post
- Non-Closing PHP Query in WordPress Loop
- Translate wordpress date from Italian to English
- How to list posts from a plugin taxonomy?
- Warning: Attempt to read property “ID” on null in D:\xampp\htdocs\yba\wp-content\themes\young-brand-child\functions.php on line 162 [closed]
- Having Issue on Redirecting With Session in WordPress
- Why is $wp->request empty in WordPress 6.0?
- Custom PHP script throws critical error ONLY when editing page
- Why am I getting a different filename? And how does WordPress load singular.php for both Page & Post? (Fresh WordPress installation)