Remove Menu(S) From Wordpress Toolbar

Hi All

I need help to get a custom function working to will remove the 2 default menus in the users Toolbar.

I found this code online and placed it in my themes child folder:
(wp-content/themes/bp-social-child/custom-functions.php
)

// modifies wordpress admin toolbar menuj
function remove_admin_bar_links() {
	global $wp_admin_bar; >
	$wp_admin_bar->remove_menu('blogs-menu');
	$wp_admin_bar->remove_menu('account-menu'); }
add_action( 'wp_before_admin_bar_render', 'remove_admin_bar_links' );

Could not get the above function to work ... hoping someone can point me in the right direction.,

Thanks

Erik

  • kampester

    Thanks Emanaku - that helped, I am getting addicted as I start going through the Wordpress Codex..... over the last 10 years, I have stay-away and resisted to get caught up in the "coding aspect" of my web business, and focusing on the business dev and content, but the power to extend wordpress has become a new joy!!!

    Here is my corrected code...

    <?php
    ////////////////////////////////////////////////////////////////////////////////
    //Kampester Custom function Adapted For MU Buddypress Newtwork  - New function
    ////////////////////////////////////////////////////////////////////////////////
    
    function admin_bar_remove_this(){
         global $wp_admin_bar;
        if(!is_super_admin()){
         $wp_admin_bar->remove_node('blogs-menu');
        $wp_admin_bar->remove_node('account-menu');
        $wp_admin_bar->remove_node('new-content');
        $wp_admin_bar->remove_node('my-sites');
           }
            $wp_admin_bar->remove_node('wp-logo');
               }
            add_action('wp_before_admin_bar_render','admin_bar_remove_this');
    
    /* Place custom code above this line. */
    ?>

    I am really enjoying my new membership at wpmdev .... big thanks to the community!

    Cheers! kampester :slight_smile:

  • 3SixtyEvolve

    Hi Erik

    Glad you got sorted. I actually tried a couple of things myself, but didn't manage to get the results you were looking for. Glad that you got it sorted in the end, with the assistance of Emanaku. So glad for our Community! It is great to see when members help each other.

    And great coding on your side!

    So enjoy the rest of your weekend and happy continued coding, I guess!

    Gina :slight_smile:

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.