How to check if the current user is Administrator in WordPress

Posted on: June 4, 2022 by Editorial Staff - Page Views: 996

In this article we will show you how to check if the current user is the administrator in WordPress. This will be very useful to check if the current user can execute certain things, like editing a page or something of that kind.

How to check if the current user is administrator

In order to check if your current logged in user is Administrator role or not, you will have to use the function called current_user_can. And to be able to check with that function, you will have to specify the capability (eg: manage_page).

If user is admin:


if ( current_user_can( 'manage_options' ) ) {
    //Something that the admin can do

If user isnt administrator:


if ( !current_user_can( 'manage_options' ) ) {
    //Something that a regular user can do

When to use this ?

For more information , please visit the official wordpress page.

Want customisation services ?

If you need help with implementation of this function into the code of your theme or plugin, or just need customisation services for wordpress or woocommerce, you can hire us.