Forums

hook wp_admin_bar only for a especific ID on multisite (1 post)

  1. lucianoes
    Member
    Posted 3 months ago #

    I have a multisite installation on example.com and users have site in example.com/user1. I would like disable on admin bar(My Sites) only the site number with id number 1(example.com), so the user can't see it on admin bar when logged, and will see My Sites/user1 . I tryed this hook, but it disables everything on 'my-sites', is there any method for to do that?

    function myfunction_admin_bar_render() {
                    global $wp_admin_bar, $current_user;
                            if ($current_user->ID != 1) {
                            $wp_admin_bar->remove_menu('my-sites');
                            }
    }
    add_action( 'wp_before_admin_bar_render', 'myfunction_admin_bar_render' );

Reply

You must log in to post.

About this Topic