Heartwood Web Design
Helping you branch out on the web and in print

How to disable the Random Visit menu in the BuddyPress admin bar

Posted by Marian Buchanan on June 24th, 2011

Here's a how-to 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.

BuddyPress is a plugin for WordPress that turns your WordPress blog into an interactive social media community -- i.e. a membership site like Facebook. It requires a BuddyPress-enabled theme to display all pages properly. Conversely, if you deactivate the BuddyPress plugin while using a BuddyPress-enabled theme, it will break your site because it will be calling for functions to which it no longer has access. If you need help converting your theme to a BuddyPress-enabled version, please feel free to ask me for help.

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:
    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:
    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!

Feel free to share on social media sites:

    About Marian Buchanan

    Marian Buchanan is the owner of Heartwood Web Design. She is fascinated by image and perception, immersed in both the artistic and technical sides of design and communications, and passionate about ethics and ethical marketing.

    7 Responses to “How to disable the Random Visit menu in the BuddyPress admin bar”

    1. Marek says:

      I’ve tried with you code but it didn’t work..

      • Which code did you try? Did you put it in your theme’s footer.php file right BEFORE the code?

        If you copied the code exactly and put it exactly where it needs to go, it’s possible that something else in the theme, or some other plugin, is interfering. What theme and plugins are you using?

    2. Jukka Aaltonen says:

      Hi Marian,

      thanks for the code tip. It just works (WP 3.3.1, BP 1.5.4, Custom Community -theme.


    3. Christoph says:

      Worked just fine for me.
      Thanks a lot!

    4. William says:

      Thanks for the tip. Worked great.