users profile link | WordPress.org

[ad_1]

Hi!

We would like to add profile links to user avatars and names in the chat.

Currently we implemented this code based on the documentation of the plugin:

/**
* Replacing user profile URL
*/
add_filter('better_messages_rest_user_item', 'activate_user_url', 100, 3 );

function activate_user_url( $item, $user_id, $include_personal ){

$item['url'] = true;
return $item;
}

And it makes the avatar and name display a tooltip ‘Go to user’s profile’ but there is no link. So we tried adding this line:

    $item['url'] = get_author_posts_url( $author_id );

//So now became:
$item['url'] = true;
$item['url'] = get_author_posts_url( $author_id );
return $item;

Now the avatar and user name display links but the url is not valid (all users link go to the same url: ‘ mywebsite.com/author/’ that givesback a 404 bc it doesn’t exist).

How can we make this be linked to the proper user profile url? (in our case we are using the url structure ‘mywebsite.com/user_role/user_id).

Looking fwd to your comments.
Best!

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer