Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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');
share|improve this question

2 Answers 2

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.

share|improve this answer
    
This worked perfectly! Thank you so much. –  achieve1 Mar 6 '13 at 16:31
    
Welcome. Please set the check(arrow) to the answer, if the answer was your solution. –  bueltge Mar 7 '13 at 11:25

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' );
share|improve this answer
    
Thank you Steve! –  achieve1 Mar 6 '13 at 16:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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