3

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!

  • I noticed if I change the 3rd parameter from administrator to edit_posts it works but if the plugin gets updated it will revert back to administrator. – bryanlewis Dec 24 '14 at 0:47
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';
}
  • Thanks so much! I really appreciate the help!!! The plugin author told me via Twitter that he added me to the committers. I'm unsure how to make the commit but if there is a tut on how to do so I'll give it a shot. – bryanlewis Dec 24 '14 at 17:40
2

I am author of commenter data plugin. I have addressed your concern and released version 2.1 which allows you to set the capability. Please take a look and let me know if you have any further query.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.