How to display a public profile page for registered users with custom slug?

I have a website where users can register, login and their edit profile, they can comment but not post.

What I am looking for is a way to display a user profile page (where I display the gravatar and the info about the user) clicking on the username.
The url must be something like “www.mywebsite.com/user/username”.

I know about author.php, but I don’t know how to link even if the user has no posts and is not an author.

UPDATE:

I managed to solve it. Instead of linking using <?php the_author_posts_link(); ?> I did an href linking to www.mysite.com/user/<?php echo $user_info->display_name; ?>

To rename the slug I installed the Edit author slug plugin, it makes the author slug editable under Settings > permalinks.

To customize the user profile, just edit authors.php as you like.

1
1

Every registered user can have profile, they don’t need to have posts.

To change WordPress author’s profile permalink, paste the following code in your functions.php:

function change_author_permalink_base() {
    global $wp_rewrite;
    $wp_rewrite->author_base = "user";
}
add_filter( 'init', 'change_author_permalink_base' );

After pasting the code, visit Settings->Permalink Structure under your wordpress admin, to flush the rewrite rules. This is a required step, otherwise you may get 404 on author profiles.

Then code your author.php. As far as linking is concerned this is totally your design decision. If you want to link the profiles from user’s comment, you can either add the new link or just link comment author name to their profile.

Remember the profile is available only if the user is registered as WordPress user.

Leave a Comment