• TheFlaneur

    (@theflaneur)


    hi,
    For most plugins editors can’t see the settings pages, but for wordpress-to-face-book and blog-metrics they can. I have used user role editors to restrict what editors can do, but they can still SEE the settings page.

    Is there a way that I can alter a plugin so that it only appears to Admin level?

    Thanks
    Jonathan

Viewing 8 replies - 1 through 8 (of 8 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    try it with a plugin: https://www.ads-software.com/extend/plugins/role-scoper/

    Or put something like this in your theme’s functions.php:

    if(is_admin() && current_user_can('editor')){
        add_action('admin_init', 'hide_plugin_settings', 0);
     }
     function hide_plugin_settings(){
       global $pagenow;
    
       // check if we are on a settings page
       if($pagenow == 'options-general.php') {
    
         // array of all restricted pages
         // example: wp-admin/options-general.php?page=blog-metrics
         $restricted = array('wordpress-to-face-book', 'blog-metrics');
    
         foreach ( $restricted as $rest  ) {
           remove_submenu_page( $pagenow, $rest );
           if(isset($_GET['page']) && $_GET['page'] == $rest) {
             wp_die( 'Restricted by Admin', 'Restricted Page' );
           }
         }
       }
     }

    Thread Starter TheFlaneur

    (@theflaneur)

    Thanks for your reply. I will give it a go and report back.

    Thread Starter TheFlaneur

    (@theflaneur)

    No, it didn’t work. Thanks for the effort though. Any one got any other ideas?

    Moderator keesiemeijer

    (@keesiemeijer)

    Did you log in as an editor? Can you give me any links where I can download these plugins?

    Thread Starter TheFlaneur

    (@theflaneur)

    https://www.xaviermedia.com/wordpress/plugins/wp-email-to-facebook.php

    I have tried leaving messages on their board but it asks for captchas and doesn’t show them, and the email bounces.

    Thanks for your help.

    Moderator keesiemeijer

    (@keesiemeijer)

    Try changing this in the code and login as an editor:

    $restricted = array('wordpress-to-face-book', 'blog-metrics');

    to this:

    $restricted = array('email-to-facebook.php');

    Thread Starter TheFlaneur

    (@theflaneur)

    You’ve done it my friend!

    Thanks very much.
    Can I just add other plugin names to that array? How do you know what name to put there? There is one more plugin that’s not so important, but do I just put the name of its php file in there?

    It’s strange – i would have thought this was necessary for many multi-user blogs.

    This is the site you were helping: The Flaneur

    Thanks again. Do you have a donation box anyway on the web?
    Jonathan

    Moderator keesiemeijer

    (@keesiemeijer)

    Can I just add other plugin names to that array?

    Yes you can, as long as it is a subpage of Settings.

    How do you know what name to put there?

    Look at the url when you are on the plugin page you want to restrict. if the url is: https://test.dev/wp-admin/options-general.php?page=email-to-facebook.php you put the “page” part in the array: “email-to-facebook.php”

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Only Admin see settings page of plugins’ is closed to new replies.