Here's a post for web designers and Do-It-Yourself website owners wishing to disable the Random Visit menu in the BuddyPress admin bar. I've posted it in the BuddyPress forums as well, but thought I'd put it here for extra ease in finding it in a search.
By default, BuddyPress replaces the regular WordPress admin bar with its own admin bar, since the latter has additional menus for all the BuddyPress community features: community activity, messages, friends, groups, your profile, privacy and other settings. But the BP admin bar also has a feature that shows up whether or not you're logged in: a Visit menu that takes you to either a Random Member profile or a Random Group main page. Unfortunately, as of the version that is current at the time of this writing (BuddyPress 1.2.8), there is no administrative option to disable only that part of the admin bar nor to disable it only for visitors who are not logged in.
So here's how that can be accomplished. Don't worry, it may look a little technical, but really it's just a matter of copying and pasting some code in the right place. You don't have to know any coding, you just have to follow the simple instructions:
In your theme’s footer.php file, right BEFORE it says <?php wp_footer(); ?>, add the following code:
- If you want the Random Visit menu to be removed for all users, whether or not they’re logged in, use this code:
<?php
remove_action( 'bp_adminbar_menus', 'bp_adminbar_random_menu', 100 );
?> - If you want the Random Visit menu to be removed only for users who are not logged in, use this code:
<?php
if (!is_user_logged_in()) {
remove_action( 'bp_adminbar_menus', 'bp_adminbar_random_menu', 100 );
}
?>
I'm sure a plugin could be made instead, but this is a quick solution in the meantime. Let me know if you find it helpful!


Yes! Please send me the newsletter!