WordPress GuideAdmin → Check Current User

How to check if the current user is Administrator in WordPress

Lines of code on a desktop computer screen.

Sometimes you need to make sure a feature, setting, or message is only visible to site administrators. WordPress makes this easy—once you understand how user roles and capabilities work behind the scenes.

Whether you’re adding admin-only messages or protecting sensitive functionality, this guide walks you through how to check if the current user is an Administrator the right way.

Get fast, reliable hosting for WordPress

Power your site with the industry’s fastest, most optimized WordPress hosting

The quick answer

To check if the currently logged-in user is an Administrator in WordPress, use the current_user_can() function with the capability ‘manage_options’.

if ( current_user_can( ‘manage_options’ ) ) {
    // The user is an Administrator
}

This works because only the Administrator role has the manage_options capability by default. WordPress user roles are built around capabilities, not role names, so it’s best practice to check for a unique capability rather than a role slug.

Why check if a user is an Administrator?

There are several reasons you might want to run code or display content only for admins:

Using a capability check ensures your features are only available to users with the proper privileges, even if the roles change later.

Use current_user_can() with admin capabilities

WordPress includes a built-in function called current_user_can() that checks whether the logged-in user has a specific capability.

Using manage_options to check for admin access

The capability manage_options is granted only to Administrators by default. If a user can manage site options, they’re almost certainly an admin.

Here’s a full example:

This can be used in your theme’s functions.php, a plugin file, or inside a template to hide or show specific content.

Other capabilities only admins have

You can also use other capabilities that are exclusive to admins, such as:

But manage_options is the most reliable and common check for admin-level access.

Why not check for ‘administrator’ as a role?

A common mistake is trying to check the role name directly, like this:

This doesn’t work because current_user_can() checks capabilities, not role slugs. Roles like ‘administrator’, ‘editor’, and ‘subscriber’ are labels that group capabilities. But WordPress permissions are based on what the user can do, not what the user is called.

If you need to check the actual role name (which is rare), use the method in the next section.

How to check a user’s role directly (if you really need to)

Sometimes you need to work with the actual role name—for example, customizing the interface or layout for different roles.

You can do this using the wp_get_current_user() function and checking the user’s assigned roles:

This approach checks the user’s role slug directly. However, it’s less flexible than using current_user_can()—especially if roles or permissions change in the future.

Securely run code for admins only

If you’re adding code that changes the admin dashboard or restricts access to settings, it’s important to run your check inside the right WordPress hook. For example, use admin_init or admin_menu when modifying admin behavior.

Here’s how to safely run admin-only code during dashboard load:

This ensures your code runs only in the dashboard, after WordPress has fully loaded the current user data.

Extra tip: check if any user (not just current user) is an Administrator

Sometimes you need to check another user’s role—maybe to show who has admin access, or validate someone’s permissions in a custom user manager.

Here’s how to check if a specific user (by ID) is an Administrator:

You can also use get_user_by( ’email’, $email ) if you prefer to look up users by email address.

Use this method when building features like:

Summary and best practices

To recap:

Checking roles the right way helps keep your site secure, flexible, and maintainable—especially as users, plugins, and permissions change over time.

Additional resources

How to use your WordPress admin login page →

How to find, use, and troubleshoot your admin page

WordPress privacy policy: how to write one and how to add it to your site →

Create a comprehensive privacy policy for your WordPress site to ensure compliance and build user trust.





Easy WordPress website maintenance tips →

7 simple steps to keep on regular rotation