1

Bbpress Wordpress Plugin have default link user profile url. The link like this: www.example.com/forum/users/(username)

The main purpose in nutshell is: I want to change the url.

Actually, I found the solution but its not perfect. The code like this:

function user_profile_link(){
    $url = 'http://localhost/example.com/profile/';
    $author_id = bbp_get_reply_author_id();
    $user_info = get_userdata($author_id);
   
    echo '<a href="'.$url.''.$user_info->user_login.'"> '. $user_info->display_name.' </a>';

}
add_filter('bbp_get_user_profile_url', 'user_profile_link');

Yes, the code working well. But the outcome is, the user profile URL not replaced and there is double URL like this image below:

image1

I think the problem solved if I display: none it. The code like this:

<style>
.bbp-author-link{
    display: none;
}

</style>

But there is one problem. The new URL that I make appeared beside the breadcrumbs like this image:

image2

I want to remove the link that appeared beside the breadcrumbs. Is there any solution? Any help is appreciated. Thank You

danronmoon
  • 3,814
  • 5
  • 34
  • 56
Hendra
  • 99
  • 9
  • ___BIG NOTE___ If you put `localhost` as the domain name, this will always attempt to look for the rest of the url on the PC running the browser!!! So it may work for you, but if you let me use the site it would NOT WORK as you think it does – RiggsFolly Dec 26 '20 at 11:55

2 Answers2

0

In a filter hook, you normally have to override the current value by returning it. Therefore try returning the new value by using the function you already created. It may remove the duplicate.

Also, use site_url() instead of $url variable because there will be issues when you use a hardcoded URL.

function user_profile_link(){
    $author_id = bbp_get_reply_author_id();
    $user_info = get_userdata($author_id);

    return site_url()."/profile/".$user_info->user_login;

}
add_filter('bbp_get_user_profile_url', 'user_profile_link');
Harshana
  • 5,151
  • 1
  • 17
  • 27
  • I found the solution, thanks to your answer. I did it like this: function user_profile_link(){ $author_id = bbp_get_reply_author_id(); $user_info = get_userdata($author_id); $url = site_url()."/profile/".$user_info->user_login; return $url; } add_filter('bbp_get_user_profile_url', 'user_profile_link'); And the problem solved. – Hendra Dec 27 '20 at 13:24
0

For this problem, I found the solution.

The code is like this:

function user_profile_link(){

    $author_id = bbp_get_reply_author_id();
    $user_info = get_userdata($author_id);

    $url = site_url()."/profile/".$user_info->user_login;

    return $url;

}
add_filter('bbp_get_user_profile_url', 'user_profile_link');
Hendra
  • 99
  • 9