Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to create a dynamic link to “my friends”


  • Kristian Yngve
    Participant

    @kristianngve

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

    http://taipeiexpats.org/members/MEMBER_NAME/friends/

    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
    Participant

    @danbp

    Hi,
    something like this may work:

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

    Kristian Yngve
    Participant

    @kristianngve

    @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?


    danbp
    Participant

    @danbp

    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
    Participant

    @kristianngve

    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.

    http://taipeiexpats.org/taipei-expats-community/

    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=http://example.com/members/me/activity">my activity stream</a>.

    See https://buddypress.trac.wordpress.org/changeset/10791 for the change.


    Kristian Yngve
    Participant

    @kristianngve

    Paul, this is fantastic. 100% works.

    I used your url to make it:

    http://example.com/members/me/friends

    **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! 🙂


    danbp
    Participant

    @danbp

    I don’t see any friend image !


    matopsiadm
    Participant

    @matopsiadm

    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.


    Salle32
    Participant

    @salle32

    Hi,
    Many thanks for this thread!
    I just wanted to add a link to http://example.com/members/USERNAME – 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 http://example.com/members/me/friends – then the user land on his/hers friends-page!
    I spent a whole day searching for this… 🙂
    //F


    commando1
    Participant

    @commando1

    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: https://mydomain.com/members/me/friendshttps://mydomain.com/members/me/settings 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.


    commando1
    Participant

    @commando1

    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?


    glengoddard
    Participant

    @glengoddard

    Hi

    I want to create a custom left menu for members.

    http://mysiteurl/members/me/friends

    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.

    profile
    messages
    notifications
    friends
    settings

    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 example.com/me/friends ? 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