Give editor permission access wordpress plugins

This tutorial explains how to give editor permission to access wordpress plugins.The following code make the plugin visible to the user with editor role.Suppose you have installed a plugin and you want to make the user with editor permissions were also able to edit and view the plugins from the wordpress admin section.

When you search in the wordpress repository you can find a lot of plugins which enable to give different user permissions. But for making the single plugin visible you can achieve by adding 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' );

Share this Tutorial