Skip to:

How to create a dynamic link to “my friends”

  • Kristian Yngve


    Initial details:

    WordPress 4.5.3 running.
    BP Press: Version 2.5.10.
    WordPress as a directory, it in root.
    I have custom functions in a child bp-custom.php.
    I’m running bbPress (standalone), ersion 2.5.10.
    NOTE: Everything all works great – just this doesn’t seem to…

    Now, I’ve seen many of the ‘[Resolved] How to create a dynamic link to “my profile”‘ forums but I need it as an image-link (in page, so not a widget), to the user’s “my friends”.

    My best guess was: having the url of the image being:-

    and, having this code in my bp-custom.php (I’ve also tried my child theme functions):-

    add_filter( ‘bp_core_enable_root_profiles’, ‘__return_true’ );


    This would allow the MEMBER_NAME (I tried adding the %username% and etc…)

    None of this works.

    Any ideas upon what I got to do?

Viewing 14 replies - 1 through 14 (of 14 total)

  • danbp


    something like this may work:

    if ( is_user_logged_in() || bp_is_active( 'friends' ) ) :
        $href = bp_loggedin_user_domain() . bp_get_friends_slug() . '/';
      echo '<a href='. $href .'><img src="path/to/img.jpg" alt="" /></a>';

    Kristian Yngve


    @danbp, thank you for getting back to me. It means a lot.

    So, if I add all this into my bp-custom.php and also have the matching <img src=”path/to/img.jpg” in the page. They both will connect up and will act as my ‘friends’ dynamic link?



    Yes and no.

    Yes because it is the minimum of php you need to create such a link.

    No, because that code should probably be in a function. But i’m unable to tell you more as you haven’t explained where exactly you want that link to be. On a page is too vague…

    Kristian Yngve


    ok, functions.php it is.

    Quite literally on a page within a general wp page template, (not widgets, not menus or anything). I want an image, (which would be amongst all my other general page content) that if you click on the image, it would (dynamically) send you to your buddypress friends list.

    You’ll notice the ‘friends’ image…

    Sorry I was too vague, danbp. I hope this makes it more clear.

    Not quite! In BuddyPress 2.6, we added support for dynamic links for user profiles.

    In your template/blog post/wherever, if you wanted a link to go to the logged-in user’s activity stream (for example), create the link to <a href=">my activity stream</a>.

    See for the change.

    Kristian Yngve


    Paul, this is fantastic. 100% works.

    I used your url to make it:

    **This link works behind an image to take anyone to their friends list.

    But, you know, I didn’t add any of the code from the change set link. Did I of needed to?

    I thank you all for helping me out with this. It’s amazing people like you guys that has made buddypress at the top! 🙂



    I don’t see any friend image !



    Thank you, thank you 🙂 I have tried so many ways to point dynamically to a user’s profile in a url for custom links. I am very new to wordpress and buddypress.



    Many thanks for this thread!
    I just wanted to add a link to – in a slider image.
    So for anyone spending time on figuring out how to write code in functions – forget it!
    It is sooo easy – just write the word /me/ in the url and all the logged in users will land on their page.
    Like – then the user land on his/hers friends-page!
    I spent a whole day searching for this… 🙂



    This doesn’t seem to be working for me. Do we need to add the php listed above to the directory? I have tried with several links: and it isn’t working. Thanks for the help.

    @commando1 As long as you have BP 2.6 or newer, the redirection will happen automatically. If it isn’t, you might try turning off other plugins to see if any of them have hijacked some URLs.



    I’m using 2.9.2. Tried disabling different plugins and testing each time. Still not working. After clicking, the url is still /members/me/friends and the “me” doesn’t change to the username.

    Is there a workaround using code?




    I want to create a custom left menu for members.


    the link does not work when I try this example. The section “[me]” remains the same. Should this field not appear as a user name?

    I just want to create a left menu for members in the following way.


    how can I do that?

    WordPress : 5.0.1
    Buddyppress : 4.1.0

    versions I use

    Don’t resurrect old threads please. A new discussion would have been fine.
    Have you tried ? I think it only works like that.

Viewing 14 replies - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.
Skip to toolbar