Plugin to hide admin menu (vertical menu bar)

I am learning to write WordPress plugin and testing out a simple case: hide the admin bar base on user role. So far I have the following in my plugin file:

$hidemenu= new HideMenu();
class HideMenu
{
    function hideMenu() {
        add_filter( 'show_admin_bar' , array($this, 'hideAdminBar'));
    }

    function hideAdminBar() {
            if (!(current_user_can("administrator")) 
                            return false;
    }
}

This is base on the example given in WordPress reference. Any idea why this is not working?

1 Answer
1

Have you looked at the WP Custom Admin Bar plugin? At the very least it has some code chunks you can deconstruct to point you in the right direction.

Leave a Comment