Answer the question
In order to leave comments, you need to log in
How to make a user profile on Wordpress and remove the redirect to the main page?
Hello. PHP, like Wordpress, I still don’t really know, but there is a desire to figure it out. I need to add a user profile so that any other person can view this profile.
I created a profile page that displays user login data and allows you to change some of this data. The link to the page looks like this localhost/profile . And I can't figure out how I can do localhost/profile/username like this . The logic, probably, should be like this .. when you go to the profile page, if there is something after "profile", then the script searches the database for a user with such a login, and if it exists, it displays data, and if not, then something then type "User not found".
So, how can I make it so that when I click on a link of the formlocalhost/profile/username , I stayed on the profile page and ran the script for that page. Because now wordpress detects the transition to the specified link as a 404 error and redirects me to the main page. And in general, I think in the right direction? Maybe what I need is done somehow differently?
Answer the question
In order to leave comments, you need to log in
In general, if someone needs to do something similar on WP, you can implement it as follows:
1) In the admin panel, create a page (for example, profile) and assign a pre-created template for it (for example, profile.php)
2) In the template page, we get the id passed by the link using
This is the case when you want any user to be able to enter the user profile, and not just its owner. If you are creating a personal account, then you can get id like this
$userID = $_GET["id"];
$current_user = wp_get_current_user();
$userID = $current_user->ID;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question