@terminator answer might work but there’s no need to create an array and use array_intersect I think since you’re only looking for one role. This might be more comprehensible:
$current_user = wp_get_current_user();
$roles = (array) $current_user->roles;
if (in_array('administrator', $roles) { /* echo whatever */ }
Don’t forget to check that ‘administrator’ is acutally the role key you want.
Related Posts:
- wp_update_user not updating
- Create custom user role (client) that can create another custom user role (employee) of that client
- How to loop through each user id?
- Ordering users of a specific role by last name
- how to add custom user capabilities using add_user_meta or something else?
- WordPress missing user roles on local dev machine. Live site works fine
- Assign second role to user
- Display user meta by different user role
- Parent User and Child User – relate users
- Assign a role to the user who registers on a form
- How to create user specific pages (not user role!)?
- How to change user role using hook
- Problems using ‘add_role’
- Change auth_cookie_expiration for specific roles and specific login times
- Saving user meta “member_id” based on user role
- Why does user_can return false for a capability during plugin deactivation?
- Hide user fields based off capability
- Assign specific editor with custom user meta “A” to all authors with custom user meta “A” and exclude all other author access
- update_user_meta on registration but only for default role type
- How to assign a custom gender to a user role?
- allow editors to edit menus?
- How to change a user’s role?
- Is there way to rename user role name without plugin?
- Is it possible to add new user Roles?
- Temporarily give ‘manage_options’ capability
- Hide specific admin users’ posts
- \WP_User Object | What’s the Difference Between {caps} and {allcaps}?
- Roles at registration (classipress)
- How to allow registered users to change their user role through frontend?
- how to change user roles for users who doesn’t have any. (about 8000 users)
- Shold I manually add ‘cap’ to admin role ?
- Contributors missing from author dropdown
- Getting a user role from the user login name
- Why is wp-login redirecting to the home page when I use this function?
- Allow contributor to view own scheduled post
- Editor and contributor roles not correct after adding function
- How are roles stored in the database?
- How to delete user roles?
- How to display user role
- I am adding a new class to my body tag if the logged in user is subscriber, need help
- How to Orderby User Role?
- Prevent custom user role to add new pages
- Hide Specific User Page
- The delete_posts capability?
- Allow role to edit users at lower level with only specific metadata
- Capabilites not working [closed]
- Set user ID at time of wp_create_user
- get approved users only ( ultimate member plugin )
- Create Super Admin that cant be deleted
- Adding Capabilities to a WordPress User Account
- Adding an additional role to an Administrator
- Allow editors to post iframes [duplicate]
- New user is assigned 2 roles: customer and superadmin
- bbPress plugin moderator roles
- how to set any post creation for pending status and let the admin approve it first?
- Allowing user to edit posts based on the post status
- Add custom role across network in multisite
- Allow user role “salesman” to view only “client” role users
- Purpose of Adding Capability to Role But Not Grant?
- bbPress: How to set conditional for specific user -or- user role, to be displayed in user profile
- Menu page with list of users
- How to check user role?
- how to remove some permissions from a shop “manager role” in woocommmerce?
- User roles are changing automatically
- Custom wordpress admin page/url “You do not have sufficient permissions to access this page.”
- user_can() not working for comment authors
- Hide front-end from every logged out user and redirect them to the default login page
- WordPress add_rewrite_rule redirection match GET variable not passing through to custom template
- ‘upload_mimes’ filter seems to be restricting viewing/downloading as well
- How to restrict an admin page, if the user is not superadmin?
- Capabilities don’t add
- Migrating Roles from one environment to another
- Letting users create a post that is a custom post type from a page
- How to create a front facing user sign up, log in and profile pages like FoodGawker.Com [closed]
- Learndash change user role after completing the course
- How to disable activation email to specific user role?
- logout users with specific role after close browser tab
- Admin user name not showing up in author dropdown
- Is there a way to allow users with “Subscriber” user role to access media library in backend and frontend
- Separate user bases or hide users of another role or connected to another minisite
- How to restrict subscriber editing other posts but read specific posts in backend
- Publishing post strips custom html element when user is not admin
- Best practices to handle multilpe roles and capabilities?
- Check what capabilitie(s) an action requires
- Allow multiple roles to specific user
- user has permission to read a custom post but it is not being shown in wordpress plugin
- Restrict custom fields based on user roles
- Select dropdown with 2 choices from foreach
- Custom Admin Menu Order for all User Roles
- translate_user_role doesn’t work
- Force “submit for review” on update?
- Allow users to change author of post
- Get users from all/specific blog by user_role and current_user role
- Is there a way for a limited user to just view the page of a post without being able to edit it?
- How do I make a draft post accessible to everyone?
- Authors Ability to Review Post from Contributors
- How to assign role to a custom registration form?
- How to add user roles? [closed]
- Check if specific role exists
- Role Scoper, don’t allow other users to see pending posts