Allow editors access to added plugins

I created a custom plugin which i want Users who are Editors to be able to use the plugin.

I found a link here to allow access for editors to allow editors to edit menusallow editors to edit menus?

using this code.

    $role_object = get_role( 'editor' );

// add $cap capability to this role object
$role_object->add_cap( 'edit_theme_options' );

So, is there a possible way i can allow Editors access to my custom added plugins

4 Answers
4

Please add the following code.

function activate_plugin_name() {
   $role = get_role( 'editor' );
   $role->add_cap( 'manage_options' ); // capability
}
// Register our activation hook
register_activation_hook( __FILE__, 'activate_plugin_name' );

function deactivate_plugin_name() {

  $role = get_role( 'editor' );
  $role->remove_cap( 'manage_options' ); // capability
}
// Register our de-activation hook
register_deactivation_hook( __FILE__, 'deactivate_plugin_name' );`

Refer my tutorial for further explanation.
http://www.pearlbells.co.uk/user-role-editor-access-wordpress-plugins/

Leave a Comment