0

I've successfully used the code from the post: Restrict ADMIN menu items based on username, replace username with an actual user's name.

The problem is the theme still shows on the main dashboard and by clicking on the theme name the admin is taken to the appearance menu which had been hidden by using the code.

Any thoughts how to get around this?

Here is the code from the post mentioned:

function remove_menus()
{
global $menu;
global $current_user;
get_currentuserinfo();

if($current_user->user_login == 'clients-username')
{
    $restricted = array(__('Posts'),
                        __('Media'),
                        __('Links'),
                        __('Pages'),
                        __('Comments'),
                        __('Appearance'),
                        __('Plugins'),
                        __('Users'),
                        __('Tools'),
                        __('Settings')
    );
    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');

2 Answers 2

0

You can remove this via javascript. The class of the theme informations is versions and the ID of this Meta Box is dashboard_right_now.

The follow screenshot demonstrate how I find this class and id via Crome Webinspector.

enter image description here

    add_action( 'admin_footer-index.php', 'fb_remove_comments_areas' );
    function () {
        ?>
        <script type="text/javascript">
            //<![CDATA[
            jQuery(document).ready( function($) {
                $( '#dashboard_right_now .versions' ).remove();
            });
            //]]>
        </script>
        <?php
    }

For more hints to this topic see this plugin, that remove all comments functions and areas.

Also another hints. To remove menu or submenu items it is better, that you use the core functions remove_menu_page() and remove_submenu_page(). Also more information and examples in this post or via search on WPSE. The last one is to use a plugin, there have options for this, like "Adminimize" for reduce the admin area for different roles, not user.

1
  • Welcome. Please set the check(arrow) to the answer, if the answer was your solution.
    – bueltge
    Commented Mar 7, 2013 at 11:25
0

You could use something like below to remove the "Right Now" Widget. Then there would be no way "Theme" to click on.

function custom_dashboard_widgets(){
    global $wp_meta_boxes;
    unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);        
}
add_action( 'wp_dashboard_setup', 'custom_dashboard_widgets' );
0

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.