BuddyDev

Search

[Resolved] Slug for current profile?

  • Participant
    Level: Yogi
    Posts: 1105
    calu on #28981

    Hi there, I want to move an element, in this case the profile tab using a hook element. The problem is the slug /members/name/profile/ which of course is dynamic.

    For your own profile, the slug /members/me/profile/ is very handy for defining your own profile, but is there a corresponding slug for current profile?

    Regards
    Carsten

  • Keymaster
    (BuddyDev Team)
    Posts: 24238
    Brajesh Singh on #28983

    Hi Carsten,
    Welcome back.

    I am sorry but I am unable to understand the question. Please help me understand it and I will assist.

    Regards
    Brajesh

  • Participant
    Level: Yogi
    Posts: 1105
    calu on #28990

    Hi Brajesh, sorry for not making myself clear, but here’s the case.

    I’m using a hook element to place tabs different places on my page. I’m then adding functions, like bp_send_private_message_button to that hook which is working fine.

    But the correct functions can be difficult to find, which is why I’m trying another approach by adding the element from the inspector instead.

    Anm example is the ‘Profile’ tab, where the markup is the same on own profile and profiles visited.
    The problem is, that the href is not changing. If I use members/me/profile, it will always point at users own profile, which is fine, but if I add this code, it will always point to jeff’s profile.

    <li id="xprofile-personal-li" class="current selected"><a id="user-xprofile" href="https://domain/members/jeff/profile/">Profil</a></li>

    I hope this clarifies.

    Maybe this approach is not working for what I am trying to achieve. The best way is to add the function, but even if I use buddypress.org hookr.io/, or a plugin to show the functions, they often do not work.

    Any suggestions would be most appreciated

    Regards
    Carsten

  • Keymaster
    (BuddyDev Team)
    Posts: 24238
    Brajesh Singh on #29149

    Hi Carsten,
    I am sorry but I still do not understand the question.

    I will list some functions, may be they may prove useful.

    
    
    $url = bp_displayed_user_domain(); // if you are on a user profile
    $url = bp_core_get_user_domain( $user_id ); // if you know the user id
    $url = bp_loggedin_user_domain(); // for the logged in user
    
    

    These are different way to get access to user’s profile url.

    Regards
    Brajesh

  • Participant
    Level: Yogi
    Posts: 1105
    calu on #29154

    Hi Brajesh, thanks for the functions.

    To be more specific, I need the function for the user xprofile button link, to put into a hook element so the tab shows here: ´bp_after_member_body´

    This code below is taken directly from the inspector, but this code will not work as it is, because it will link to the user “John” even if you are visiting user “Ben”‘s profile.

    <li id="xprofile-personal-li" class="current selected"><a id="user-xprofile" href="https://domain/members/John/profile/">Profil</a></li>

    I have tried to put on of the functions into php tags

    ´<?php $url = bp_displayed_user_domain(); ?>´

    • This reply was modified 4 years ago by calu.
    • This reply was modified 4 years ago by calu.
  • Participant
    Level: Yogi
    Posts: 1105
    calu on #29221

    Hi Brajesh, just to clarify this, then eg

    href=$url = bp_loggedin_user_domain();"

    replaces

    href="https://domain/members/carstenadmin/profile/change-avatar/"

    or am I wrong?

  • Participant
    Level: Yogi
    Posts: 1105
    calu on #29223

    Yes, I can see I am wrong, it breaks my site.

    What I do not understand is, that these functions you gave to me seems to be urls, but apparently I can’t just replace a normal url with these.

    So my question is, how do I use these functions/urls?

    Regards
    Carsten

    • This reply was modified 4 years ago by calu.
    • This reply was modified 4 years ago by calu.
    • This reply was modified 4 years ago by calu.
    • This reply was modified 4 years ago by calu.
  • Keymaster
    (BuddyDev Team)
    Posts: 24238
    Brajesh Singh on #29246

    Hi, you may use this

    
    
    <?php
     $url = bp_loggedin_user_domain() . 'profile';
    ?>
    
    

    and then in href

    
    
    href="<?php echo esc_url( $url );?>
    
    

    or

    
    
    href="<?php echo esc_url( bp_loggedin_user_domain(). 'profile' );?>"
    
    

    Regards
    Brajesh

  • Participant
    Level: Yogi
    Posts: 1105
    calu on #29247

    Hi Brajesh, thank you very much for offering this extraordinary support, even if the topic might be off scope

    Regards
    Carsten

  • Keymaster
    (BuddyDev Team)
    Posts: 24238
    Brajesh Singh on #29259

    Thank you.

The topic ‘ [Resolved] Slug for current profile?’ is closed to new replies.

This topic is: resolved