You worded it as you want to check if user has administrator role. It is considered more proper to check for capability, relevant to specific action.
In practice this is usually expressed as current_user_can( 'manage_options' )
for current user. For arbitrary user it would be user_can( $user_id, 'manage_options' )
.
Of course this is capability that stands for general configuration of the site. Depending on your purpose you might want to use a different one, see list in roles and capabilities documentation.
Related Posts:
- 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 check if a user is in a specific role?
- Add a button to users.php
- create users to site with specific language
- Display sortable User meta column in admin panel user’s page
- Users Unable to Access Dashboard/Posts/Pages
- 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
- Logout USER form backoffice after 30 minutes of inactivity [closed]
- Create new user from phpMyAdmin
- Newly created user role not displaying on users screen
- How to check if a user is in a specific role?
- Hook into form handle from admin users table
- 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
- How to restrict dashboard access to Admins only?
- Admin Page Redirect
- Adding fields to the “Add New User” screen in the dashboard
- How to filter users on admin users page by custom meta field?
- How to prevent access to wp-admin for certain user roles?
- Grouping users under parent user
- 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]
- Add mass action to wp-admin/users.php
- Only allow administrators and editors to access wp-admin
- Prevent from deleting any user role but subscriber
- \WP_User Object | What’s the Difference Between {caps} and {allcaps}?
- What is the capability that permits access to WP-Admin?
- 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?
- 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
- create shortcode to list users with specific meta key value
- Are User Levels Still Currently Used?
- Adding Custom Capabilites
- Restrict Author role to only 3 wp-admin pages
- Users disappeared from wp-admin
- Updating wp_user_level on user update
- transition_post_status not working via Quick Edit
- Why is unfiltered_upload not working despite being enabled?
- Users create/join groups
- 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]
- Create reviews and star-rating for user accounts in wp-admin [closed]
- 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?
- Can I Create a Second Admin Level User Role?
- Is there a filter to edit html of user-edit.php
- Change users.php WP_User_Query
- Assigning multiple or additional capabilities to specific users or how to create additional roles like bbpress roles?
- Get users with different roles and call function on each of them (user_meta)
- 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?
- how do I add role and capability after I create a new user
- 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”
- Update user role for expired membership
- How to change the URL of sub menu page?
- Login issue with subdomain installs
- Hook into add_user_role and update based on new and removed roles
- How to Moderate Edits to User Profiles?
- wp_get_current_user Not working
- Give wp-admin access for shop managers
- restrict admin panel sections to users
- Add another role to a user when they click a button?
- CSRF attack to create USER
- adding existing menu page on new customer user role
- In admin manage users page, how can I stop users with certain privileges from editing users with other privileges?
- How to keep the plugin submenu open on viewing a custom version of users.php?
- Checkbox not showing as checked on UserProfile (even with checked=”checked”)
- Cannot login in WordPress even after changing hash password in phpmyadmin
- WordPress User profile page fields missing
- Get author meta of all writers
- Display and Allow users to edit their own profiles
- Creating Custom user type just like custom post
- Anyone Can Register
- Is it possible to tell if a user is logged into WordPress from looking at the cookies which are set?
- 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?