BuddyDev

Add Extra links to BuddyPress User Profile Menu & BuddyPress Group Menu

Ever wanted to add extra links to BuddyPress user profile menu  or group menu? It is easy and to be honest, too easy.

Life is all about choices, so why not have some here too.

We have got two choices here.

  • Simply hardcode links using the code ( because we are in hurry )
  • Or Use WordPress nav menu to manage extra links ( Now, we have started caring about the future )

Let's go with the simple way first. After all, we need motivation, quick motivation.

We hook to 'bp_member_options_nav' to add any extra links. Just make sure to use "li" as the link wrapper. These links are going inside the "ul" element.

The above link adds Google and your beloved BuddyDev 🙂 to the user profile. You can change that to anything you like. Here is a screenshot as proof that I am not lying 🙂

user-profile-menu-custom-links

Similarly, you can do the same for groups as shown below.

Not putting any screenshot, you need to trust me sometimes 🙂

That's enough for our simple but not so flexible way. Let us explore what lies ahead.

Strategy 2: Using WordPress Nav menus for adding extra links.

As the title says, it is just like that. In our second strategy, we will register 2 nav menu locations, one for profile and one for group. After that,  you the superman( oops super admin ) can add/delete any links to these menu locations by creating new menus. These links will be added to the user profile/groups by the power of the almighty actions.

Registering nav menu locations:-

That was easy. Now is your chance to visit the Dashboard and confirm that we are going on the right path.  Please visit Dashboard->Appearance->Menus and you will notice these two as shown below. You need proof, here you go 🙂

menu-locations

Now, go ahead and create some menu and assign to these location. All set, now we simply render all these links in the profile or group( based on locations. I wanted to tell you an story about locations, but some other day ).

Render links in profile menu:-

Simple as it is, here is the code.

Here is my admin screenshot

menu-links-admin

and here is profile view

buddypress-user-profile-extra-links

And for groups:-

Now, you are enlightened enough to take your journey from here onward. Go ahead, experiment. May the force be with you 🙂

 There are no secrets to success. It is the result of preparation, hard work and learning from failure. – Colin L. Powell

17 Responses to Add Extra links to BuddyPress User Profile Menu & BuddyPress Group Menu

  • hi Brajesh sorry i m so can u tell in which to put the code

    • Hi Amit,
      No problem. You can put the code in your theme's functions.php or in the bp-custom.php
      https://buddydev.com/docs/guides/guides/buddypress-guides/what-is-bp-custom-php/

      • and how can i make it visible to other user in profile navigation

      • Hi Brajesh Singh,

        I want to add a simple link bellow the registration form. Actually I want to put a direct download link or an external download link. It will download a form.

        I added the following codes into my child theme function.php and its shows on the menu perfectly. But no link in the registration filed or in the profile.

        Then I tried to use bp-custom.php. I saw there is no bp-custom.php file inside my buddypress. So i created a file and paste the code inside it.

        But no result.

        Can you please help?

        • hi Sabiha,
          you don't need these.

          Your need is simple and easily doable in a few lines. Please post in our forums and we will help with the code.

          Regards
          Brajesh

  • I just love the way you write. No matter how difficult, you always find a way to make it simpler. Always nice, and helpful. Keep up with the good work.. 🙂

    &,
    I have a question on the custom menu added via WordPress nav menu (because now we care about the future), how do you change it's position and have it come before a default buddypress menu item?

    Thank you.

  • I am having trouble here.

    I create a bp-custom.php file in the plugins directory and pasted the code given here into it. Now I have the code at the top of every page but nothing you describe here is happening.

    • Hi Patrick,
      Please make sure you have the opening php tag in your file

      That will make it work.

  • Hey, very nice article! You helped me a lot.

    I have just one problem, I want the custom links I added just to be viewable for logged-in users. Is this possible?

    I know that it is not right, but something like this:

    Thanks for your help!

    • Hi Alessio,
      Thank you.
      Please put this line inside the function

      That will make the links visible to the logged in user only.

      If you want to make the links visible to the profile owner only, you can change that condition to this

      Hope that helps.
      If you need more help, please do post in our forums and we will assist.

      Regards
      Brajesh

  • Love this plugin, I do have a question how do I keep my new menu item link on the profile page and open up like Friends, Activity and or Profile. This would be a great help instead of moving my users away from the form.

  • Question. Is it possible to add different links on different groups? For example, 1 group will have the additional link to Google, while another group has a link to Amazon?

    Thx.

  • Hi — and thanks for this code. Is there any way to adjust the placement of the links relative to the existing list, such that the added links are not at the end of the profile list, but in the middle or position 1, 2, etc.

    • Sorry for the delayed reply.

      With the above code, It is not. But you can do it with