1

I have two plugins in the dashboard, SEO Wordpress and Custom Content Type Manager, and for security reasons I want to hide these from dashboard. How to do that?

I tried to hide the SEO Wordpress with this:

// Remove Admin Dashboard menus
 function wp_admin_dashboard_remove_menus() {
     global $menu;
     $restricted = array(('Comments'), __('Users'), __('Updates'), __('wpseo_dashboard'));
     end ($menu);
     while (prev($menu)){
         $value = explode(' ',$menu[key($menu)][0]);
         if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){
             unset($menu[key($menu)]);
         }
     }
 }

 add_action('admin_menu', 'wp_admin_dashboard_remove_menus');

Tried many combinations like:

__('wpseo')
__('wp-seo')
__('wp_seo')

But the SEO menu did not hide.

  • 3
    Have you researched anything here? Please, tell us what you found and why it didn't work. – brasofilo Apr 29 '13 at 15:12
  • 2
    The WordPress Seo menu is already limited to users who can manage_options ie. admins, do you have admins who you don't want viewing/using it? I'd have a similar question for the other plugin if i could find the relevant piece of source code, but that's too many files to check via the plugin svn manually. – t31os Apr 29 '13 at 18:24
5

Wordpress SEO

If you want to remove the admin menu:

wpseo

you can do that with:

function hide_wpseo() {
       remove_action('admin_menu', 'zeo_options_menu');
}
add_action( 'init', 'hide_wpseo');

where it will be removed for all users.

WordPress SEO by Yoast

To hide the admin menu:

admin menu

and the admin menu bar:

admin menu bar

one can use:

function hide_yoastseo() {
    remove_action('admin_bar_menu', 'wpseo_admin_bar_menu',95);
    remove_menu_page('wpseo_dashboard');
}
add_action( 'admin_init', 'hide_yoastseo');

where it will be hidden for all users.

Custom Content Type Manager

Here one can hide the admin menu:

admin menu

from all users with:

function hide_cctm() {
    remove_menu_page('cctm');
}
add_action('admin_init', 'hide_cctm');
  • 1
    It's already limited to users with manage_options, see: source here. – t31os Apr 29 '13 at 18:25
  • @birgire i refer to Yoast WordPress SEO plugin. For the code which is above, this is not work. – user24259 Apr 29 '13 at 18:37
  • 1
    @t31os thanks for noticing it ;-) I updated the code to remove it for all users. – birgire Apr 29 '13 at 19:00
  • 1
    @MikeD I hope I got the right plugin this time ;-) – birgire Apr 29 '13 at 19:01
  • 2
    Unbelievable. That was three times (out of five) a slightly wrong name. Right, bilgire? Err, bitgire, no bigire. ;) Sorry, I just had to share my amazement. – tfrommen Apr 29 '13 at 20:50
0

Do you want to hide it for a specific kind of user like an author? If so, you can use the Advanced Access Manager plugin http://wordpress.org/extend/plugins/advanced-access-manager/

With this plugin you can decide what the user(group) has access to in the backend and also what permissions he/she has.

  • thanks for the answer. I want to hide it for the admin. Sorry, but i don't want to use a plugin for this. I try to solve it with a bit of code. – user24259 Apr 29 '13 at 15:45
0

For removing plugin's menu from multisite dashboard

foreach($GLOBALS[ 'menu' ] as $key => $value) {

    remove_menu_page($value[2]);

}

For adding menu use add_menu_page();

Your Answer

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