If you only need this for current user current_user_can()
accepts both roles and capabilities.
UPDATE: Passing a role name to current_user_can()
is no longer guaranteed to work correctly (see #22624). Instead, you may wish to check user role:
$user = wp_get_current_user();
if ( in_array( 'author', (array) $user->roles ) ) {
//The user has the "author" role
}
Related Posts:
- Check if user is admin by user ID
- create users to site with specific language
- Users Unable to Access Dashboard/Posts/Pages
- Logout USER form backoffice after 30 minutes of inactivity [closed]
- Newly created user role not displaying on users screen
- How to check if a user is in a specific role?
- Extend user search in the users.php page to allow for searching by role and excluding specified email domains from the “users search” input box
- How to restrict dashboard access to Admins only?
- Admin Page Redirect
- How to prevent access to wp-admin for certain user roles?
- How to display the user that published a pending post?
- Custom user role that can only edit specific (non-custom-type) page and all child pages [duplicate]
- Only allow administrators and editors to access wp-admin
- Add a button to users.php
- Prevent from deleting any user role but subscriber
- What is the capability that permits access to WP-Admin?
- Display sortable User meta column in admin panel user’s page
- Displaying which Role the current user is assigned to
- How to display multiple custom columns in the wp-admin users.php?
- Hooking into register_admin_color_schemes
- How to hide a specific user role option in a user role list?
- Adding HTML/Text to Top of Subscriber’s Profile Backend Page
- Removing user fields [duplicate]
- Custom role based users are not able to access wp-admin
- wp-admin edit user url wont show up correct url [closed]
- Custom roles showing HTML entities in title form field
- Only allow administrators and editors to access wp-admin
- Stop loading “collaborators” users on add new post or page?
- Distinguish profile user and admin user IDs / get ID of user being edited
- Uncheck the box “Send User Notification” by default on new-user.php
- Detecting all admins that are logged in
- Subscribers become Authors after Upgrade? / Mass Update of Users?
- Stopping user deletion from running on error
- Allow administrators to pick post author on custom post type edit screen
- Filter dropdown in users.php “delete user” bulk edit screen
- Add count for new registered user in Users tab
- Adding Custom Capabilites
- Restrict Author role to only 3 wp-admin pages
- Users disappeared from wp-admin
- Why is unfiltered_upload not working despite being enabled?
- WP admin user search doesn’t return all users
- Hide username discovery
- How to get Role Subscribe Users on Admin Menu only in Pages in WordPress
- Downgrade admin account by mistake
- How to set where user is redirected to after logging in at wp-login?
- I accidentally deleted an admin user and all their content is now gone from the site. [closed]
- Restrict submitters from wp-admin [duplicate]
- Nickname field isn’t appearing in Admin
- How to allow WordPress updates to only one specific administrator?
- User Capabilities are not available in WP REST permission callback?
- Is there a filter to edit html of user-edit.php
- Change users.php WP_User_Query
- Create new user from phpMyAdmin
- How do I make it so that the all users page is not a white screen?
- User Roles: How to hide a plugin from showing in WP-Admin?
- Is WordPress secure enough for a multi-user article directory?
- define two login page url
- On Users (user.php) in wp-admin disable/hide “Bulk Actions” and “Change Role To”
- Login issue with subdomain installs
- Hook into form handle from admin users table
- Give wp-admin access for shop managers
- restrict admin panel sections to users
- CSRF attack to create USER
- adding existing menu page on new customer user role
- How to keep the plugin submenu open on viewing a custom version of users.php?
- Cannot login in WordPress even after changing hash password in phpmyadmin
- WordPress User profile page fields missing
- Anyone Can Register
- Is it possible to tell if a user is logged into WordPress from looking at the cookies which are set?
- Extend user search in the Wp backend area on the users.php page to allow for searching by email domain and role from the “users search” input box
- WordPress Users page missing user count next to different types of users
- How to create a User Role and give permission to only use Web Stories plugin?
- Searching for a custom meta from user.php in the admin
- how to Hide all products except the General Manager role in the WordPress admin panel?
- Remove “From computer” media tab for posts with existing attachments?
- How-to Delay The Capability To Publish Posts?
- Make certain pages uneditable by editors?
- How can I check if the admin bar is visible to the current user?
- SSL Partially breaking admin panel and elementor
- the_author_meta(‘user_url’, $author->ID) not working properly. how can I solve this?
- Woocommerce: Add column to ORDERS admin page with items purchased
- How to declutter admin columns
- How to make the front-end RTL without changing the admin panel language?
- Updating wp_user_level on user update
- wp-admin redirects to 404
- Generate PDF using tcpdf from WordPress admin side custom page [closed]
- Editor’s role in WP
- Is wp-admin/about.php required? Can i omit it from my website
- How many people are allowed to use same wordpress account at the same time?
- WP Admin Login keeps redirecting to login
- can’t create user without email for an author after converting single site to multisite
- WordPress Redirects to a cancelled domain, need to change it but can’t get to the admin portal
- WordPress Admin Login Issue
- Wp-admin Redirection loop after moving to subdirectory
- Show only childs and grandchilds of certain post in admin
- WordPress logged in but no access to wp-admin
- Changed the path to wp-login and now can’t access WPress dashboard
- Creating another wordpress site as sub-domain of a wordpress site
- Mixed content and expired session issues with SSL and wp-admin
- wp-admin blank page after admin login and all security off