WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Hiding Admin Features from Subscribers (3 posts)

  1. Alberto
    Member
    Posted 2 years ago #

    Hello Everyone!

    I've just upgraded my WP site to the latest 3.3 release and noticed that the subscriber admin panel now has additional features than before.

    Previously subscribers were only able to see and edit their profiles under the admin panel, but now they are able to see "Posts", "Comments" and "Tools" under their admin panel.

    I am wondering if there might be any way to hide these features from the subscribers admin panel. I am worried it adds a layer of complexity to my subscribers who ultimately have no need for any of these additional features.

    Please help! Thank you so much in advance.

    Alberto

  2. luisleguisamo
    Member
    Posted 2 years ago #

    I found this online and tweaked it.
    Works on my end. I'm using 3.3:

    function hide_menus () {
    global $menu;
    
    if(current_user_can('subscriber')):
    	$restricted = array(__('Posts'), __('Tools'), __('Comments'));
    	end ($menu);
    	while (prev($menu)){
    		$value = explode(' ',$menu[key($menu)][0]);
    		if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){unset($menu[key($menu)]);}
    	}
    endif;
    }
    add_action('admin_menu', 'hide_menus');

    I hope that helps!

    EDIT:
    I placed the above code in my functions.php theme file.

  3. Alberto
    Member
    Posted 2 years ago #

    luisleguisamo - Perfect! That worked like a charm.

    Thanks for your help with this one!

Topic Closed

This topic has been closed to new replies.

About this Topic