0

So i've been googling around and i'm trying to figure out a plain simple solution to my problem. I've tried several things but they are simply not working. I just got into WordPress and i have to edit some permissions. I want to give the Editor rank access to ONE specific plugin. I've determined that this is the piece of code that returns a false or true statement ( Are you an admin? ).

The editor should have sufficient rights to work in the settings tab of this plugin. This is the piece of code. I'm not asking for straight answers, i just need some advice.

if (is_admin() ){
add_action('admin_menu', 'rooster_admin_menu');
add_action('plugins_loaded', 'rst_add_registration');
add_action('plugins_loaded', 'rst_cancel_registration');
add_action('plugins_loaded', 'rst_delete_event');
function rooster_admin_menu(){
    add_options_page('Rooster', 'Rooster', 'administrator', 'rooster', 'rooster_html_page');
}
3

2 Answers 2

0

You should be able to do this via the option_page_capability_{$option_page} hook - like:

function wpse151616_grant_access_to_options_page_for editors() {
    return 'edit_posts';
}
add_filter( 'option_page_capability_rooster', 
            'wpse151616_grant_access_to_options_page_for editors' );

For possible return values take a look at Roles and Capabilities. The variable part - {$option_page} - of the hook name is substituted by the menu slug - $menu_slug - value of your add_options_page() call.

2
  • My pleasure, don't forget to tick the answer, if it solved your problem. @user54667 Commented Jun 24, 2014 at 13:18
  • I will not! Don't worry :)
    – user54667
    Commented Jun 24, 2014 at 14:43
0

I've done some research and I've found another way to fix this issue. I assigned permissions to editors using the function :)

  if ( is_admin() )  
{  
    add_action( 'admin_menu', 'add_plugin_for_editors' );  
}  

function add_plugin_for_editors()   
{  
    if (!current_user_can( 'manage_options' ))  
    {  
        add_menu_page('Rooster', 'Rooster', 'editor', 'rooster', 'rooster_html_page');  
    }  
}  
1
  • 1
    But with this they only can access the page. They still can't save the form.
    – leymannx
    Commented Apr 16, 2019 at 20:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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