User role editor access wordpress plugins

This tutorial I am explaining how to give user role editor access wordpress plugins. Suppose you have installed a plugin but the plugin is not visible to the user with role editor.Here I am showing how to make the plugin accessible to the editor without installing the additional plugins or extensions.

In the wordpress repository you can came across lot of the plugins with set user permissions to different roles.But just for a plugin it is not worth to install additional plugins. In that case please use the following code.

User role editor access wordpress plugins

Here I am explaining based on newsletter subscription plugin.For making the plugin accessible to the editor please add the following to the plugins main file.

user role editor access wordpress plugins

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' );

Please copy and paste the above code the wordpress plugins main file and replace the plugin name with your plugin and change the capability as well.

If you have any further queries please leave a reply.

Share this Tutorial

2 comments on “User role editor access wordpress plugins

  1. Tito on

    Hi, I tried a plugin for a user role however its not appearing on their dashboard.
    Plugin: wp_statistics
    Code : loaded from wp-statistics/wp-statistics.php
    user role: lilli
    capability: access

    I used your example.
    can u help?

    Reply
    • pearl on

      Please send me the code you have added in the plugin.

      $role = get_role( ‘editor’ );
      $role->remove_cap( ‘manage_options’ ); //

      Change the manage_options with the menu capability

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

*