WordPress allow us to manage users with Roles and Capabilities.
Basically user roles are the combination of multiple capabilities. Each user role have 1 or many capabilities.
Capacities are the tasks which user user role can perform such as:
- Create Post
- Install Plugin
- Add Users
- Delete Theme
- etc.
We know that Administrator user can do Add Users because of Administrator user role have add_users
capability.
And Subscriber user role can’t Install Plugin because of subscriber user role have NOT have such capability.
Additionally we can change the capability of user roles with below functions:
- add_cap() – Add capability to the user role.
- remove_cap() – Remove capability to the user role.
Also, We can create new manipulate user roles with:
- add_role() – Add new user role.
- remove_role() – Remove existing user role.
Let’s see default user roles and there capabilities.
User Roles: User Roles:
In WordPress we have 6 types of users roles:
- Super Administrator (In multisite)
- Administrator
- Editor
- Author
- Contributor
- Subscriber
Each user role have some list of capabilities to perform certain actions.
Let’s check them from Subscriber to Administrator.
I have created the Subscriber to Administrator user roles to demostrate there capabitlies. And used plugin User Switching to switch Subscriber to Administrator user role.
You can read more about user switching at – https://maheshwaghmare.com/doc/user-switching
Subscriber Subscriber
Subscriber user role can update their profile and have only only capability.
Lets check the subscriber user capability with function wp_get_current_user().
I have used below code snippet to check current user role & capability.
if( ! function_exists( 'prefix_current_user_details' ) ) : function prefix_current_user_details() { $current_user = wp_get_current_user(); echo '<pre>'; print_r( $current_user ); wp_die(); } add_action( 'admin_head', 'prefix_current_user_details' ); endif;
Note: Use this in your testing site.
The output of above code is below:
WP_User Object ( [data] => stdClass Object ( [ID] => 7 [user_login] => test-subscriber [user_pass] => $P$BONUJ.QIM95cS3aYRYUE6LP4g2Pmii1 [user_nicename] => test-subscriber [user_email] => subscriber@example.com [user_url] => [user_registered] => 2020-05-05 15:32:59 [user_activation_key] => [user_status] => 0 [display_name] => test-subscriber ) [ID] => 7 [caps] => Array ( [subscriber] => 1 ) [cap_key] => wp_capabilities [roles] => Array ( [0] => subscriber ) [allcaps] => Array ( [read] => 1 [level_0] => 1 [subscriber] => 1 ) [filter] => [site_id:WP_User:private] => 1 )
Here, The Subscriber user have below capabilities:
- read - level_0 - subscriber
Note: level_0 to level_10 are deprecated from WordPress version 2.0. Instead of it we have Capabilities.
The subscriber
itself the name of the user role.
So, Subscriber user have only ONE capability which is read
.
Administration Screens Access:
- Dashboard
- Users > Your Profile
Perform:
- Edit Profile Information
Contributor Contributor
Somebody who can write and manage their own posts but cannot publish them.
The Contributor user role can:
Perform:
- Write Post
- Manage Their Own Posts
- But CANNOT publish them
- View Post Comments
Administration Screens Access:
- Dashboard
- Users > Your Profile
- Posts
- Posts > Add New
- Comments
- Comments > Awaiting Moderation
Capabilities:
- edit_posts - read - delete_posts - read_blocks
Deprecated capabilities:
- level_1 - level_0
Debug Info:
WP_User Object ( [data] => stdClass Object ( [ID] => 4 [user_login] => test-contributor [user_pass] => $P$BqHjAeogEmsZETBu8tHE4M0hBWZhNe. [user_nicename] => test-contributor [user_email] => contributor@example.com [user_url] => [user_registered] => 2020-05-05 15:32:53 [user_activation_key] => [user_status] => 0 [display_name] => test-contributor ) [ID] => 4 [caps] => Array ( [contributor] => 1 ) [cap_key] => wp_capabilities [roles] => Array ( [0] => contributor ) [allcaps] => Array ( [edit_posts] => 1 [read] => 1 [level_1] => 1 [level_0] => 1 [delete_posts] => 1 [read_blocks] => 1 [contributor] => 1 ) [filter] => [site_id:WP_User:private] => 1 )
Author Author
Somebody who can publish and manage their own posts.
The Author user role can:
Perform:
- Write Post
- Manage Their Own Posts
- User can edit their published posts.
- View all posts.
- Upload media.
Administration Screens Access:
- Dashboard
- Media
- Media > Add New
- Posts
- Posts > Add New
- Comments
- Comments > Awaiting Moderation
- Users > Your Profile
Capabilities:
- upload_files - edit_posts - edit_published_posts - publish_posts - read - delete_posts - delete_published_posts - edit_blocks - publish_blocks - read_blocks - delete_blocks - delete_published_blocks - edit_published_blocks - create_blocks
Deprecated capabilities:
- level_2 - level_1 - level_0
Debug Info:
WP_User Object ( [data] => stdClass Object ( [ID] => 6 [user_login] => test-author [user_pass] => $P$B8xeKIvSu9Lg9.9t2W7No6kqhV7Fb2. [user_nicename] => test-author [user_email] => author@example.com [user_url] => [user_registered] => 2020-05-05 15:32:57 [user_activation_key] => [user_status] => 0 [display_name] => test-author ) [ID] => 6 [caps] => Array ( [author] => 1 ) [cap_key] => wp_capabilities [roles] => Array ( [0] => author ) [allcaps] => Array ( [upload_files] => 1 [edit_posts] => 1 [edit_published_posts] => 1 [publish_posts] => 1 [read] => 1 [level_2] => 1 [level_1] => 1 [level_0] => 1 [delete_posts] => 1 [delete_published_posts] => 1 [edit_blocks] => 1 [publish_blocks] => 1 [read_blocks] => 1 [delete_blocks] => 1 [delete_published_blocks] => 1 [edit_published_blocks] => 1 [create_blocks] => 1 [author] => 1 ) [filter] => [site_id:WP_User:private] => 1 )
Editor Editor
Somebody who can publish and manage posts including the posts of other users.
Perform:
Administration Screens Access:
- Dashboard
- Media
- Media > Add New
- Posts
- Posts > Add New
- Comments
- Comments > Awaiting Moderation
- Users > Your Profile
Capabilities:
- moderate_comments - manage_categories - manage_links - upload_files - unfiltered_html - edit_posts - edit_others_posts - edit_published_posts - publish_posts - edit_pages - read - edit_others_pages - edit_published_pages - publish_pages - delete_pages - delete_others_pages - delete_published_pages - delete_posts - delete_others_posts - delete_published_posts - delete_private_posts - edit_private_posts - read_private_posts - delete_private_pages - edit_private_pages - read_private_pages - edit_blocks - edit_others_blocks - publish_blocks - read_private_blocks - read_blocks - delete_blocks - delete_private_blocks - delete_published_blocks - delete_others_blocks - edit_private_blocks - edit_published_blocks - create_blocks - editor
Deprecated
- level_7 - level_6 - level_5 - level_4 - level_3 - level_2 - level_1 - level_0
Debug Info:
WP_User Object ( [data] => stdClass Object ( [ID] => 5 [user_login] => test-editor [user_pass] => $P$BUBG1qm03gprqZ3Arr.9keB14PEOxM/ [user_nicename] => test-editor [user_email] => editor@example.com [user_url] => [user_registered] => 2020-05-05 15:32:55 [user_activation_key] => [user_status] => 0 [display_name] => test-editor ) [ID] => 5 [caps] => Array ( [editor] => 1 ) [cap_key] => wp_capabilities [roles] => Array ( [0] => editor ) [allcaps] => Array ( [moderate_comments] => 1 [manage_categories] => 1 [manage_links] => 1 [upload_files] => 1 [unfiltered_html] => 1 [edit_posts] => 1 [edit_others_posts] => 1 [edit_published_posts] => 1 [publish_posts] => 1 [edit_pages] => 1 [read] => 1 [level_7] => 1 [level_6] => 1 [level_5] => 1 [level_4] => 1 [level_3] => 1 [level_2] => 1 [level_1] => 1 [level_0] => 1 [edit_others_pages] => 1 [edit_published_pages] => 1 [publish_pages] => 1 [delete_pages] => 1 [delete_others_pages] => 1 [delete_published_pages] => 1 [delete_posts] => 1 [delete_others_posts] => 1 [delete_published_posts] => 1 [delete_private_posts] => 1 [edit_private_posts] => 1 [read_private_posts] => 1 [delete_private_pages] => 1 [edit_private_pages] => 1 [read_private_pages] => 1 [edit_blocks] => 1 [edit_others_blocks] => 1 [publish_blocks] => 1 [read_private_blocks] => 1 [read_blocks] => 1 [delete_blocks] => 1 [delete_private_blocks] => 1 [delete_published_blocks] => 1 [delete_others_blocks] => 1 [edit_private_blocks] => 1 [edit_published_blocks] => 1 [create_blocks] => 1 [editor] => 1 ) [filter] => [site_id:WP_User:private] => 1 )
Administrator Administrator
Somebody who has access to all the administration features within a single site.
Perform:
Administration Screens Access:
- Dashboard
- Media
- Media > Add New
- Posts
- Posts > Add New
- Comments
- Comments > Awaiting Moderation
- Users > Your Profile
Capabilities:
- switch_themes - edit_themes - activate_plugins - edit_plugins - edit_users - edit_files - manage_options - moderate_comments - manage_categories - manage_links - upload_files - import - unfiltered_html - edit_posts - edit_others_posts - edit_published_posts - publish_posts - edit_pages - read - edit_others_pages - edit_published_pages - publish_pages - delete_pages - delete_others_pages - delete_published_pages - delete_posts - delete_others_posts - delete_published_posts - delete_private_posts - edit_private_posts - read_private_posts - delete_private_pages - edit_private_pages - read_private_pages - delete_users - create_users - unfiltered_upload - edit_dashboard - update_plugins - delete_plugins - install_plugins - update_themes - install_themes - update_core - list_users - remove_users - promote_users - edit_theme_options - delete_themes - export - manage_woocommerce - view_woocommerce_reports - edit_product - read_product - delete_product - edit_products - edit_others_products - publish_products - read_private_products - delete_products - delete_private_products - delete_published_products - delete_others_products - edit_private_products - edit_published_products - manage_product_terms - edit_product_terms - delete_product_terms - assign_product_terms - edit_shop_order - read_shop_order - delete_shop_order - edit_shop_orders - edit_others_shop_orders - publish_shop_orders - read_private_shop_orders - delete_shop_orders - delete_private_shop_orders - delete_published_shop_orders - delete_others_shop_orders - edit_private_shop_orders - edit_published_shop_orders - manage_shop_order_terms - edit_shop_order_terms - delete_shop_order_terms - assign_shop_order_terms - edit_shop_coupon - read_shop_coupon - delete_shop_coupon - edit_shop_coupons - edit_others_shop_coupons - publish_shop_coupons - read_private_shop_coupons - delete_shop_coupons - delete_private_shop_coupons - delete_published_shop_coupons - delete_others_shop_coupons - edit_private_shop_coupons - edit_published_shop_coupons - manage_shop_coupon_terms - edit_shop_coupon_terms - delete_shop_coupon_terms - assign_shop_coupon_terms - edit_shop_webhook - read_shop_webhook - delete_shop_webhook - edit_shop_webhooks - edit_others_shop_webhooks - publish_shop_webhooks - read_private_shop_webhooks - delete_shop_webhooks - delete_private_shop_webhooks - delete_published_shop_webhooks - delete_others_shop_webhooks - edit_private_shop_webhooks - edit_published_shop_webhooks - manage_shop_webhook_terms - edit_shop_webhook_terms - delete_shop_webhook_terms - assign_shop_webhook_terms - edit_blocks - edit_others_blocks - publish_blocks - read_private_blocks - read_blocks - delete_blocks - delete_private_blocks - delete_published_blocks - delete_others_blocks - edit_private_blocks - edit_published_blocks - create_blocks - read_flexible_invoice - read_private_flexible_invoices - edit_flexible_invoice - edit_flexible_invoices - edit_others_flexible_invoices - edit_private_flexible_invoices - edit_published_flexible_invoices - delete_flexible_invoice - delete_flexible_invoices - delete_others_flexible_invoices - delete_private_flexible_invoices - delete_published_flexible_invoices - publish_flexible_invoices - schedule_broadcasts - cancel_broadcasts - view_broadcasts - add_contacts - delete_contacts - edit_contacts - view_contacts - import_contacts - export_contacts - add_emails - delete_emails - edit_emails - send_emails - execute_events - cancel_events - schedule_events - view_events - add_funnels - delete_funnels - edit_funnels - export_funnels - import_funnels - add_tags - delete_tags - edit_tags - manage_tags - view_reports - export_reports - perform_bulk_actions - download_files - download_contact_files - administrator
Deprecated
- level_10 - level_9 - level_8 - level_7 - level_6 - level_5 - level_4 - level_3 - level_2 - level_1 - level_0
Debug Info:
WP_User Object ( [data] => stdClass Object ( [ID] => 1 [user_login] => admin [user_pass] => $P$BAGMQXFKfqmrKcuYeuSI1vBZLupc2t/ [user_nicename] => admin [user_email] => mwaghmare7@gmail.com [user_url] => [user_registered] => 2020-03-23 08:00:32 [user_activation_key] => [user_status] => 0 [display_name] => admin ) [ID] => 1 [caps] => Array ( [administrator] => 1 ) [cap_key] => wp_capabilities [roles] => Array ( [0] => administrator ) [allcaps] => Array ( [switch_themes] => 1 [edit_themes] => 1 [activate_plugins] => 1 [edit_plugins] => 1 [edit_users] => 1 [edit_files] => 1 [manage_options] => 1 [moderate_comments] => 1 [manage_categories] => 1 [manage_links] => 1 [upload_files] => 1 [import] => 1 [unfiltered_html] => 1 [edit_posts] => 1 [edit_others_posts] => 1 [edit_published_posts] => 1 [publish_posts] => 1 [edit_pages] => 1 [read] => 1 [level_10] => 1 [level_9] => 1 [level_8] => 1 [level_7] => 1 [level_6] => 1 [level_5] => 1 [level_4] => 1 [level_3] => 1 [level_2] => 1 [level_1] => 1 [level_0] => 1 [edit_others_pages] => 1 [edit_published_pages] => 1 [publish_pages] => 1 [delete_pages] => 1 [delete_others_pages] => 1 [delete_published_pages] => 1 [delete_posts] => 1 [delete_others_posts] => 1 [delete_published_posts] => 1 [delete_private_posts] => 1 [edit_private_posts] => 1 [read_private_posts] => 1 [delete_private_pages] => 1 [edit_private_pages] => 1 [read_private_pages] => 1 [delete_users] => 1 [create_users] => 1 [unfiltered_upload] => 1 [edit_dashboard] => 1 [update_plugins] => 1 [delete_plugins] => 1 [install_plugins] => 1 [update_themes] => 1 [install_themes] => 1 [update_core] => 1 [list_users] => 1 [remove_users] => 1 [promote_users] => 1 [edit_theme_options] => 1 [delete_themes] => 1 [export] => 1 [manage_woocommerce] => 1 [view_woocommerce_reports] => 1 [edit_product] => 1 [read_product] => 1 [delete_product] => 1 [edit_products] => 1 [edit_others_products] => 1 [publish_products] => 1 [read_private_products] => 1 [delete_products] => 1 [delete_private_products] => 1 [delete_published_products] => 1 [delete_others_products] => 1 [edit_private_products] => 1 [edit_published_products] => 1 [manage_product_terms] => 1 [edit_product_terms] => 1 [delete_product_terms] => 1 [assign_product_terms] => 1 [edit_shop_order] => 1 [read_shop_order] => 1 [delete_shop_order] => 1 [edit_shop_orders] => 1 [edit_others_shop_orders] => 1 [publish_shop_orders] => 1 [read_private_shop_orders] => 1 [delete_shop_orders] => 1 [delete_private_shop_orders] => 1 [delete_published_shop_orders] => 1 [delete_others_shop_orders] => 1 [edit_private_shop_orders] => 1 [edit_published_shop_orders] => 1 [manage_shop_order_terms] => 1 [edit_shop_order_terms] => 1 [delete_shop_order_terms] => 1 [assign_shop_order_terms] => 1 [edit_shop_coupon] => 1 [read_shop_coupon] => 1 [delete_shop_coupon] => 1 [edit_shop_coupons] => 1 [edit_others_shop_coupons] => 1 [publish_shop_coupons] => 1 [read_private_shop_coupons] => 1 [delete_shop_coupons] => 1 [delete_private_shop_coupons] => 1 [delete_published_shop_coupons] => 1 [delete_others_shop_coupons] => 1 [edit_private_shop_coupons] => 1 [edit_published_shop_coupons] => 1 [manage_shop_coupon_terms] => 1 [edit_shop_coupon_terms] => 1 [delete_shop_coupon_terms] => 1 [assign_shop_coupon_terms] => 1 [edit_shop_webhook] => 1 [read_shop_webhook] => 1 [delete_shop_webhook] => 1 [edit_shop_webhooks] => 1 [edit_others_shop_webhooks] => 1 [publish_shop_webhooks] => 1 [read_private_shop_webhooks] => 1 [delete_shop_webhooks] => 1 [delete_private_shop_webhooks] => 1 [delete_published_shop_webhooks] => 1 [delete_others_shop_webhooks] => 1 [edit_private_shop_webhooks] => 1 [edit_published_shop_webhooks] => 1 [manage_shop_webhook_terms] => 1 [edit_shop_webhook_terms] => 1 [delete_shop_webhook_terms] => 1 [assign_shop_webhook_terms] => 1 [edit_blocks] => 1 [edit_others_blocks] => 1 [publish_blocks] => 1 [read_private_blocks] => 1 [read_blocks] => 1 [delete_blocks] => 1 [delete_private_blocks] => 1 [delete_published_blocks] => 1 [delete_others_blocks] => 1 [edit_private_blocks] => 1 [edit_published_blocks] => 1 [create_blocks] => 1 [read_flexible_invoice] => 1 [read_private_flexible_invoices] => 1 [edit_flexible_invoice] => 1 [edit_flexible_invoices] => 1 [edit_others_flexible_invoices] => 1 [edit_private_flexible_invoices] => 1 [edit_published_flexible_invoices] => 1 [delete_flexible_invoice] => 1 [delete_flexible_invoices] => 1 [delete_others_flexible_invoices] => 1 [delete_private_flexible_invoices] => 1 [delete_published_flexible_invoices] => 1 [publish_flexible_invoices] => 1 [schedule_broadcasts] => 1 [cancel_broadcasts] => 1 [view_broadcasts] => 1 [add_contacts] => 1 [delete_contacts] => 1 [edit_contacts] => 1 [view_contacts] => 1 [import_contacts] => 1 [export_contacts] => 1 [add_emails] => 1 [delete_emails] => 1 [edit_emails] => 1 [send_emails] => 1 [execute_events] => 1 [cancel_events] => 1 [schedule_events] => 1 [view_events] => 1 [add_funnels] => 1 [delete_funnels] => 1 [edit_funnels] => 1 [export_funnels] => 1 [import_funnels] => 1 [add_tags] => 1 [delete_tags] => 1 [edit_tags] => 1 [manage_tags] => 1 [view_reports] => 1 [export_reports] => 1 [perform_bulk_actions] => 1 [download_files] => 1 [download_contact_files] => 1 [administrator] => 1 ) [filter] => [site_id:WP_User:private] => 1 )
Super Administrator Super Administrator
Somebody with access to the site network administration features and all other features.article.
- switch_themes - edit_themes - activate_plugins - edit_plugins - edit_users - edit_files - manage_options - moderate_comments - manage_categories - manage_links - upload_files - import - unfiltered_html - edit_posts - edit_others_posts - edit_published_posts - publish_posts - edit_pages - read - edit_others_pages - edit_published_pages - publish_pages - delete_pages - delete_others_pages - delete_published_pages - delete_posts - delete_others_posts - delete_published_posts - delete_private_posts - edit_private_posts - read_private_posts - delete_private_pages - edit_private_pages - read_private_pages - delete_users - create_users - unfiltered_upload - edit_dashboard - update_plugins - delete_plugins - install_plugins - update_themes - install_themes - update_core - list_users - remove_users - promote_users - edit_theme_options - delete_themes - export - administrator
Deprecated
- level_0 - level_1 - level_2 - level_3 - level_4 - level_5 - level_6 - level_7 - level_8 - level_9 - level_10
Debug Info:
WP_User Object ( [data] => stdClass Object ( [ID] => 1 [user_login] => admin [user_pass] => $P$BJaBtdjg0ANVXIBtY1gboa5yLi0Q6Y1 [user_nicename] => admin [user_email] => mwaghmare7@gmail.com [user_url] => [user_registered] => 2019-03-14 02:10:29 [user_activation_key] => [user_status] => 0 [display_name] => admin [spam] => 0 [deleted] => 0 ) [ID] => 1 [caps] => Array ( [administrator] => 1 ) [cap_key] => wp_2_capabilities [roles] => Array ( [0] => administrator ) [allcaps] => Array ( [switch_themes] => 1 [edit_themes] => 1 [activate_plugins] => 1 [edit_plugins] => 1 [edit_users] => 1 [edit_files] => 1 [manage_options] => 1 [moderate_comments] => 1 [manage_categories] => 1 [manage_links] => 1 [upload_files] => 1 [import] => 1 [unfiltered_html] => 1 [edit_posts] => 1 [edit_others_posts] => 1 [edit_published_posts] => 1 [publish_posts] => 1 [edit_pages] => 1 [read] => 1 [level_10] => 1 [level_9] => 1 [level_8] => 1 [level_7] => 1 [level_6] => 1 [level_5] => 1 [level_4] => 1 [level_3] => 1 [level_2] => 1 [level_1] => 1 [level_0] => 1 [edit_others_pages] => 1 [edit_published_pages] => 1 [publish_pages] => 1 [delete_pages] => 1 [delete_others_pages] => 1 [delete_published_pages] => 1 [delete_posts] => 1 [delete_others_posts] => 1 [delete_published_posts] => 1 [delete_private_posts] => 1 [edit_private_posts] => 1 [read_private_posts] => 1 [delete_private_pages] => 1 [edit_private_pages] => 1 [read_private_pages] => 1 [delete_users] => 1 [create_users] => 1 [unfiltered_upload] => 1 [edit_dashboard] => 1 [update_plugins] => 1 [delete_plugins] => 1 [install_plugins] => 1 [update_themes] => 1 [install_themes] => 1 [update_core] => 1 [list_users] => 1 [remove_users] => 1 [promote_users] => 1 [edit_theme_options] => 1 [delete_themes] => 1 [export] => 1 [administrator] => 1 ) [filter] => [site_id:WP_User:private] => 2 )