admin管理员组文章数量:1330564
I wondered if anyone has a solution for the following scenario i would like to force when a user registers Display name publicly to Nickname by default instead of first name and last name which is what is set by default in WP.
Many thanks in advance JM
I wondered if anyone has a solution for the following scenario i would like to force when a user registers Display name publicly to Nickname by default instead of first name and last name which is what is set by default in WP.
Many thanks in advance JM
Share Improve this question asked Feb 8, 2019 at 14:30 user160843user160843 111 silver badge2 bronze badges 3- one addition to the question the objective is that when users generate posts written by field displays their nickname. – user160843 Commented Feb 8, 2019 at 14:32
- You can edit your question to include that note, but before you do, can you reword it? I don't understand what you mean by "written by field" – Tom J Nowell ♦ Commented Feb 8, 2019 at 14:40
- I think they mean they want the byline on posts to use the author's nickname. – Jacob Peattie Commented Feb 8, 2019 at 15:33
2 Answers
Reset to default 1You can use the user_register hook, which is fired after the user is registered, to set the name to whatever you like:
function fix_user_display_name($user_id) {
$user = get_user_by('id', $user_id);
$display_name = $user->user_nicename;
wp_update_user(array(
'ID' => $user_id,
'display_name' => $display_name
)) ;
}
add_action("user_register", "fix_user_display_name", 20);[1]
Hi Guys in response to further details on my answer, so basically i searched for plugin solutions in preference to adding code (i am not a developer) and found a plugin that does the job very well called change display name publicly as. Hope this feedback is relevant and helpful.
many thanks,
J
本文标签: user registrationForce display name to nickname wp
版权声明:本文标题:user registration - Force display name to nickname wp 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742222026a2435504.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论