WordPress.org

Forums

Yoast SEO
[Plugin: WordPress SEO by Yoast] Remove Dashboard Menu for some users (4 posts)

  1. WiSch
    Member
    Posted 3 years ago #

    Hi.
    I want to remove the "SEO"-menu from the dashboard for some users.
    So I tried the following code in the functions.php wich worked well for other menuitems: remove_menu_page('wpseo_dashboard');
    I also tried: remove_menu_page('admin.php?page=wpseo_dashboard');
    Both won't work... but I don't know why. :(
    When I took a look in the $menu I found:
    [104] => Array
    (
    [0] => SEO
    [1] => manage_options
    [2] => wpseo_dashboard
    [3] => WordPress SEO Configuration
    [4] => menu-top toplevel_page_wpseo_dashboard menu-top-last
    [5] => toplevel_page_wpseo_dashboard
    [6] => http://www.myurl.de/wp-content/plugins/wordpress-seo/images/yoast-icon.png )
    )
    So, there I can see the "wpseo_dashboard"!

    Can someone help here? Thanks!

    http://wordpress.org/extend/plugins/wordpress-seo/

  2. seejaeger
    Member
    Posted 2 years ago #

    I too am looking for a solution to this issue.

    Will post my findings...

  3. seejaeger
    Member
    Posted 2 years ago #

    WordPress 3.4.2
    Wordpress SEO 1.2.8.7

    To restrict dashboard menu items per user, I insert code (like shown below) into my functions.php file. All of the other restrictions are working. However, I still cannot find what term grabs the WordPress SEO plugin 'SEO' sidebar menu item.

    I need to provide my client with a restricted admin access, but I prefer not to have the client playing around with the SEO settings.

    functions.php
    ---------------------------------

    function remove_menus()
    {
    global $menu;
    global $current_user;
    get_currentuserinfo();
    if($current_user->user_login == 'username')
    {
    $restricted = array( __('Links'), __('Pages'), __('Dashboard'), __('Contact'), __('Appearance'), __('Plugins'),__('Users'), __('Tools'), __('Performance') );

    end ($menu);
    while (prev($menu)){
    $value = explode(' ',$menu[key($menu)][0]);
    if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){unset($menu[key($menu)]);}
    }// end while
    }// end if
    }

    add_action('admin_menu', 'remove_menus');

    ---------------------------------

    I've tried restricting the following with no luck:
    __('wpseo')
    __('wp-seo')
    __('wp_seo')
    __('WordpressSeo')
    __('wordpress-seo')
    __('wordpress_seo')
    __('wpseodashboard')
    __('wpseo_dashboard')
    __('wpseo-dashboard')

    If anyone has solved this issue please feel free to chime in.
    For now, until I find a solution, I will have to disable the plugin.

  4. seejaeger
    Member
    Posted 2 years ago #

    After disabling the plugin, the WP Dashboard then FORCED the next active plugin's menu item to display.

    Let me further explain...
    In my case the WP-DBManager plugin's menu was FORCED to be displayed.
    I was able to previously disable this menu with the line __('Database')
    However, disabling the WordPress SEO plugin has forced the Database menu to display even with that line of code active in my functions.php

    What this means is the failure to disable the WordPress SEO menu from the dashboard may not solely be a name/label issue...

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Yoast SEO
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic