• Resolved autox420

    (@autox420)


    I know about this function.

    function my_filtered_post_username($username, $userID) {
      return '<a href="MY_CUSTOM_LINK">'.$username.'</a>';
    }
    add_filter('asgarosforum_filter_post_username', 'my_filtered_post_username', 10, 2);

    But how do i make so if i click a username it redirects to his buddypress profile?

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author Asgaros

    (@asgaros)

    Hi,

    please use the following filter to change the profile link:
    – asgarosforum_filter_profile_link

    The filter takes two arguments:
    – $profileLink
    – $userObject

    I dont know how BuddyPress works, but I think they have some functions which you can use to create the links for an user.

    Thread Starter autox420

    (@autox420)

    Well with the code i posted in the first thread the usernames are clickable when viewing a forum thread. But when viewing forum the usernames arnt clickable how do i solve that?

    I think i can solve the buddypress thingy i need but can you help me on the way?

    <a href="https://test.com/members/<forum_username>">
    <a href="https://test.com/members/<worpdress_username>">

    Do you understand what i need help with?
    Thanks!

    • This reply was modified 7 years ago by autox420.
    • This reply was modified 7 years ago by autox420.
    • This reply was modified 7 years ago by autox420.
    • This reply was modified 7 years ago by autox420.
    • This reply was modified 7 years ago by autox420.
    • This reply was modified 7 years ago by autox420.
    Plugin Author Asgaros

    (@asgaros)

    Yes, but the code basically puts another link around an already existing link to your usernames. Thats why it would be better when you use the filter I mentioned while the profile-functionality is enabled. In this case, the links will lead to your buddypress-profile.

    Yworld

    (@yworld)

    Hi
    Something like this ??

    function my_filtered_post_username($username, $author_id) {
     $profile = bp_core_get_userlink($author_id);
    return '<b>'.$profile.'</b>';
    }
    add_filter('asgarosforum_filter_profile_link', 'my_filtered_post_username', 10, 2);

    $profileLink – only to change

    • This reply was modified 7 years ago by Yworld.
    Thread Starter autox420

    (@autox420)

    @asgaros well when i disable profiles in settings then it works in someway. It redirects me to https://test.com/members/

    But i need it to redirect to.

    <a href="https://test.com/members/<forum_username>">
    or
    <a href="https://test.com/members/<worpdress_username>">

    The code im using is.

    function my_filtered_post_username($username, $userID) {
      return '<a href="https://test.com/members/">'.$username.'</a>';
    }
    add_filter('asgarosforum_filter_post_username', 'my_filtered_post_username', 10, 2);

    @yworld.
    Doesnt work.

    • This reply was modified 7 years ago by autox420.
    • This reply was modified 7 years ago by autox420.
    • This reply was modified 7 years ago by autox420.
    Thread Starter autox420

    (@autox420)

    Getting closer but still not there.
    This links all users to themselfs.

    function my_filtered_post_username($username, $userID) {
    	
    global $current_user;
    $name = $current_user->user_login;
    
      return '<a href="https://test.com/members/'.$name.'">'.$username.'</a>';
    }
    add_filter('asgarosforum_filter_post_username', 'my_filtered_post_username', 10, 2);
    Plugin Author Asgaros

    (@asgaros)

    Please try this code:

    function my_filtered_post_username($username, $userID) {	
    $user = get_userdata($userID);
    $name = $user->user_login;
    return '<a href="https://test.com/members/'.$name.'">'.$username.'</a>';
    }
    add_filter('asgarosforum_filter_post_username', 'my_filtered_post_username', 10, 2);
    Yworld

    (@yworld)

    $profile = bp_core_get_userlink($author_id);

    Thread Starter autox420

    (@autox420)

    Found a solution: https://www.asgaros.de/support/?view=thread&id=197

    function my_filtered_post_username($username, $author_id) {
     $profile = bp_core_get_userlink($author_id);
    return '<b>'.$profile.'</b>';
    }
    add_filter('asgarosforum_filter_post_username', 'my_filtered_post_username', 10, 2);

    Yes you were right in a previous post. I did something wrong there.
    Its solved now!

    And yes that other code also worked.

    But how do i make the usernames clickable everywhere?
    Its only clickable in the threads.
    How to make them clickable everywhere in the forum?

    • This reply was modified 7 years ago by autox420.
    • This reply was modified 7 years ago by autox420.
    • This reply was modified 7 years ago by autox420.
    • This reply was modified 7 years ago by autox420.
    Yworld

    (@yworld)

    filter – asgarosforum_filter_profile_link

    Plugin Author Asgaros

    (@asgaros)

    Yes, for this you have to use the asgarosforum_filter_profile_link filter with activated profile functionality so it puts a link automatically around the usernames:

    function_my_filtered_link($link, $user) {
    return 'https://test.com/members/'.$user->login;
    }
    Thread Starter autox420

    (@autox420)

    Well you are trying to explain it like pros. Im not a pro im just a simple user who follows easy instructions.

    The buddypress linking is working yes. But only when im view a forum thread.

    This is code that i use right now.

    function my_filtered_post_username($username, $author_id) {
     $profile = bp_core_get_userlink($author_id);
    return '<b>'.$profile.'</b>';
    }
    add_filter('asgarosforum_filter_post_username', 'my_filtered_post_username', 10, 2);

    I want that usernames also can be clickable when viewing the forum categories and the forum where the threads are.
    I have tryed to change modify and so on the things you wrote. But it doesnt work for me the best i got was that usernames redirect to the forum thread.

    Can you please give me the right code if you can?

    Plugin Author Asgaros

    (@asgaros)

    As I said before: You cant use the asgarosforum_filter_post_username for it because its not intended for such kind of things. Use the asgarosforum_filter_profile_link filter instead and ensure that the profile-functionality is enabled:

    function my_filtered_link($link, $user) {
    return 'https://test.com/members/'.$user->login;
    }
    add_filter('asgarosforum_filter_profile_link', 'my_filtered_link', 10, 2);
Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Profile link to buddypress how?’ is closed to new replies.