$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>redirect - How to get user details by name|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

redirect - How to get user details by name

matteradmin18PV0评论

I am new in WordPress.

I want to get user details on frontend without login in WordPress when the user types his name in browser URL (Like example/{user-name})

and hit enter, User redirect a new page like example/{user-name} or example/user/{user-name}

Please, anyone, help me how to complete this task.

Thanks in advance

I am new in WordPress.

I want to get user details on frontend without login in WordPress when the user types his name in browser URL (Like example/{user-name})

and hit enter, User redirect a new page like example/{user-name} or example/user/{user-name}

Please, anyone, help me how to complete this task.

Thanks in advance

Share Improve this question asked Mar 20, 2019 at 7:09 Rakesh PatidarRakesh Patidar 433 bronze badges 2
  • How are you implementing this is it through API or it is a page? – Pratik bhatt Commented Mar 20, 2019 at 10:50
  • I am implementing on the frontend for the visitor can access normal information about admin. Visitor hit admin name in URL then get information. – Rakesh Patidar Commented Mar 20, 2019 at 10:56
Add a comment  | 

1 Answer 1

Reset to default 0

"Users" are basically "authors" in WordPress so those pages are available at example/author/{user-name}/ (with or without the trailing slash) and what you are looking for is actually to change the "author permalink base" for the URL rewrite. eg:

add_action( 'init', 'set_custom_author_base' );
function set_custom_author_base() {
    global $wp_rewrite;
    $wp_rewrite->author_base = 'user';
}

You can then add (or modify) an author.php template in your child theme directory to output what you would like to show of the user (but of course not sharing private user info in public URLs like this.)

Of course this is a simple example, it might be easier to do it with a plugin like this if you want to keep the /author/ for some roles but change it for others.

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far