redirect - How to get user details by name

I am new in WordPress.I want to get user details on frontend without login in WordPress when the user types his name in

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745673470a4639544.html

相关推荐

  • redirect - How to get user details by name

    I am new in WordPress.I want to get user details on frontend without login in WordPress when the user types his name in

    6小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信