Customize access to options according to user roles

By default, you must be an Administrator to have access to any and all of WP Rocket's settings and options. 

But you can customize this, and grant other user roles access to some or all of WP Rocket's options. There are 2 possible ways to do this: 

In this article

Customize access with User Role Editor plugin

Assign capabilities

  1. Install and activate the User Role Editor plugin
  2. Go to Users > User Role Editor
  3. Choose which user role to edit
  4. Click on WP Rocket from the "Group" list
  5. Select which capabilities to give this user role

Available capabilities

The following capabilities can be assigned to users to provide access to very specific settings in WP Rocket:

rocket_purge_cache

User will have access to the Clear Cache, or Clear and preload cache if the Preload is enabled, link in the WP Rocket admin toolbar.

rocket_purge_posts

User will be able clear the cache of specific pieces of content

Heads up! This capability cannot be assigned alone, the rocket_purge_cache capability must also be assigned in order for it to work.

rocket_purge_terms

User will be able to clear the cache of specific taxonomies like categories:

Heads up! This capability cannot be assigned alone, the rocket_purge_cache capability must also be assigned in order for it to work.

rocket_purge_users

If the user has been given access to manage other users in WordPress, and User Cache is enabled in WP Rocket, they will be able to clear the cache of specific users:

Heads up! This capability cannot be assigned alone, the rocket_purge_cache capability must also be assigned in order for it to work.

rocket_purge_sucuri_cache

If the Sucuri add-on is enabled in WP Rocket, AND the user has been granted access to rocket_manage_options, the user will be able to clear the Sucuri cache from the add-on tab

rocket_regenerate_critical_css

If Load CSS Asynchronously is activated in WP Rocket, the user will have access to the Regenerate Critical Path CSS link in the admin toolbar:

rocket_manage_options

Heads up! This capability should not be assigned alone, it requires some additional capabilities to work correctly. See below.

User will be able to access and manage the WP Rocket settings page. When assigning this capability, it's required to also assign them the following capabilities as well: 

  • rocket_regenerate_critical_css
  • rocket_purge_cache
  • rocket_purge_cloudflare_cache
  • rocket_purge_sucuri_cache
  • rocket_preload_cache
  • rocket_remove_unused_css

Use custom code

You can write your own custom functions to assign capabilities. Here is an example of how to give the Author role the ability to purge posts:

function wp_rocket_add_purge_posts_to_author() {
	// gets the author role object
	$role = get_role('author');
 
	// add a new capability
	$role->add_cap('rocket_purge_posts', true);
}
add_action('init', 'wp_rocket_add_purge_posts_to_author', 12);

Capabilities are persistent and saved in the database. Even if you remove the code snippet, the user role will still have the capability until you explicitly remove it with remove_cap

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.