Editor access to plugin settings

I’m trying to give access to an user with the role Editor to this plugin settings page: https://wordpress.org/plugins/commenter-data/

In the code of this plugin on line 31 of commenter.php there is this function:

function cd_setting_page(){

   add_options_page( 'Commenter data Settings', 'Commenter data Settings', 'administrator', 'commenterdata-settings', array( $this, 'cd_renderer' ));
}

This only allows for the administrator user role to access the settings page.

I’m wondering if there is a way to override or add a filter to this function in my themes functions.php file in order for my user with the user role Editor to access this plugins settings.

Any help would be great!

2 Answers
2

Unfortunately, the plugin author did not leave room for a filter. But I did request one for you here.

I suggested changing:

/* Add option page */
function cd_setting_page(){

    add_options_page( 'Commenter data Settings', 'Commenter data Settings', 'administrator', 'commenterdata-settings', array( $this, 'cd_renderer' ));
}

to

/* Add option page */
        function cd_setting_page(){
$cap = apply_filters( 'commenter_data_settings_page_capability_filter', 'administrator' );
            add_options_page( 'Commenter data Settings', 'Commenter data Settings', $cap, 'commenterdata-settings', array( $this, 'cd_renderer' ));
        }

so you could use this in your theme’s functions.php file if the plugin author makes it exactly what I suggested.

    add_filter( 'commenter_data_settings_page_capability_filter','my_settings_page_filter' );

function my_settings_page_filter( $cap )
{
// allow Editor role the ability to access Commenter Data Settings Page
return 'edit_posts';
}

Leave a Comment