admin管理员组

文章数量:1122826

I want every user to get a profile in the front-end of my website. So I want to visit website/user/user-name and view all the information of this user. Is this somehow possible?

I would like to do this without a plug-in. All things I'll found on Google did include a plug-in like Front-End Only Users..

I want every user to get a profile in the front-end of my website. So I want to visit website.com/user/user-name and view all the information of this user. Is this somehow possible?

I would like to do this without a plug-in. All things I'll found on Google did include a plug-in like Front-End Only Users..

Share Improve this question asked Dec 7, 2015 at 11:05 ronnyrrronnyrr 3832 gold badges6 silver badges16 bronze badges 1
  • In a page template use <?php global $current_user; var_dump($current_user); ?>. For example: <?php the_author_meta( 'first_name', $current_user->ID ); ?>. – Mayeenul Islam Commented Dec 7, 2015 at 11:14
Add a comment  | 

2 Answers 2

Reset to default 0

You need to do 2 different things to achieve this.

URL Structure:

Getting the URL in your desired format: http://website.com/user/username

By default, user's archive URL is something like this http://website.com/author/username

There is a plugin to change author slug, install this plugin and set the slug to user

Plugin: https://wordpress.org/plugins/rename-author-slug/

[Note: I'm the author of this plugin]

Displaying info:

Customize your author.php file in theme directory and show specific information.

In this file, you can get any of information a user has.

To get a user's display-name, simply use <?php the_author_meta('display_name' ); ?>

Or to get his first name, use <?php the_author_meta('first_name' ); ?>

I would do it slightly different. I have a similar case but I created a custom post type with a full custom structure on the profile of that user. Using ACF, I linked the user account to the post in the custom post file. That way you have full control over how the user profile is structured and whatever fields are needed.

本文标签: pagesUser profile in frontend