Customize Access to Options According to User Roles

This feature is currently only available to Rocket Testers of 3.4-Beta.


In this Article

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: 

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

rocket_manage_options

User will be able to access and manage the WP Rocket settings page and all options.

rocket_purge_cache

User will have access to the Clear Cache link in the WP Rocket admin toolbar

rocket_purge_posts

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

rocket_purge_terms

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

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:

rocket_purge_opcache

User will have access to the Purge OPcache link in the admin toolbar:

rocket_purge_cloudflare_cache

If the Cloudflare add-on is enabled in WP Rocket, the user will have access to the Clear Cloudflare cache link in the admin toolbar: 

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_preload_cache

If Preload is activated in WP Rocket, the user will have access to the Preload cache link in the admin toolbar:

rocket_regenerate_critical_css

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

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.