If you want this for all future users then hook into the user_register
event and update it there.
Pull the WP_User
using get_userdata
and wp_update_user
info with the new display name.
add_action( 'user_register', 'wpse_20160110_user_register', 10, 1 );
function wpse_20160110_user_register ( $user_id ) {
// get the user data
$user_info = get_userdata( $user_id );
// pick our default display name
$display_publicly_as = $user_info->user_login;
// update the display name
wp_update_user( array ('ID' => $user_id, 'display_name' => $display_publicly_as));
}
If you want to set this every login then hook wp_login
using PHP_INT_MAX
.
function wpse_20160110_wp_login ( $user_login, $user ) {
wp_update_user(array('ID' => $user->ID, 'display_name' => $user_login));
}
add_action('wp_login', 'wpse_20160110_wp_login', PHP_INT_MAX, 2);
Related Posts:
- Organizing Code in your WordPress Theme's functions.php File?
- Limit widget to certain sidebar?
- Highlight custom widgets in the admin area?
- Change the link of ‘Howdy’ at the top right
- Delete Post From front Page ( With Wp-admin restriction )
- Hide a page in the admin end without a plugin?
- Prevent from deleting any user role but subscriber
- How to get the password and username of the add new user form (admin back end) in wordpress
- 500 Internal Server Error after Register dialog, but with successful registration
- Create custom fields as image uploads [duplicate]
- Is there a quick way to find out what posts haven’t been tagged?
- “WordPress installations is currently out of date” problem with difficult situation [closed]
- Is WordPress secure enough for a multi-user article directory?
- Add a custom field when adding / editing a page / post in admin panel
- define two login page url
- How to add a field on the user creation page?
- Link with password is not sent to the new user
- How to Fix WordPress Not Saving Settings?
- Unable to Add User after Site Migration
- Google flagged a wp-admin redirect as phishing
- Undeletable posts, users or other content
- Impossible User Registration
- Only Admin receives email
- How to restrict dashboard access to Admins only?
- How to disable the “Post Lock/Edit Lock”?
- How can I control the position in the admin menu of items added by plugins?
- I’m getting a 404 message when I try to access wpadmin
- wordpress wp-admin css not loading
- Check if user is admin by user ID
- Unable to login to my wordpress site. reauth=1 redirection loop
- How to change admin bar color scheme in MP6 / WP 3.8 front end?
- Can I add custom attributes while adding inline scripts?
- Email as Username in registration
- create users to site with specific language
- How to wrap admin menus and menu headers in additional divs without modifying the WordPress core?
- Display sortable User meta column in admin panel user’s page
- wp-login.php — redirect logged in users to custom URL
- Hooking into register_admin_color_schemes
- Which actions can update/change .php files?
- Blank page for edit.php
- Upload media file problem
- comment_form – show all fields when logged in
- How to change how long items are kept in the trash?
- How can I add ‘view mode’ to screen options for pages and cpts?
- Using List Table Filters for ALL Custom Post Types
- In the WordPress admin, how can I find out which page (themes.php, widgets.php, etc.) I’m on?
- What is the practical difference between is_admin() and is_blog_admin()?
- How do I set the homepage to the WordPress Admin Dashboard login?
- Today, without warning, all admin panel logins redirect to home page after login. non-admin users logins work well
- Reusable content block
- Wrong wp-admin URL
- What is wrong with this code to remove wp admin bar from one page
- Admin search not working for any type of post
- Adding Custom Capabilites
- Display checked in checkbox theme admin page when reloaded
- Why is unfiltered_upload not working despite being enabled?
- List All Enqueued Scripts and Styles
- Can I add my own profile.php?
- Wp-admin is giving me an error “Sorry, you are not allowed to access this page.”. I do have access to the wp-admin besides the dashboard itself
- Add menu option to “New Post” menu in admin bar
- How can I disable all external url Google in WordPress backend?
- if it possible to get all notifications from all plugins and core?
- wp-admin page redirecting to 404 error page
- ASCII to Unicode conversion and then save the data into database using WP post editor field
- How to use default WP form elements to interact with custom DB table?
- How to replace “Password Protected” text with icon in Admin
- 100+ terms in any taxonomy slows down post updates?
- Is WordPress Suitable for my site?
- Disable or lock parent pages from being edited in wordpress admin
- How login is possible, if I deny login page via .htaccess with allow ip
- Unable to display WordPress admin bar in the frontend as an admin
- unsuccessful attempt to change domains- wordpress re-routing to old domain
- How can I limit page parent dropdown to show only author’s own pages?
- How to Find The Email of a WP Admin Account
- how can I change the font on Edit Post area (admin dashboard)
- buddypress remove username from autocomplete
- Icons are missing from Visual Editor
- how can provide access to wp_admin page for non wp_users?
- jQuery UI Datepicker error
- Can’t connect to WP-Admin, blank error message
- Adding re-type email and check it if the email match
- 404 errors when updating options in admin dashboard
- Can’t access wp-admin after http to https change
- Programtically selecting image URL in Media Library modal
- WordPress /wp-admin redirect to wrong port in docker
- How do I fix the 403 error for wp-admin/admin-ajax.php?
- Strange Popup Ad on my WordPress Admin Dashboard
- Trying to list user and post information from (wp_includes/post.php ) causes Fatal error
- Get Post ID in Admin Edit screen otherwise generate it?
- Cannot login in WordPress even after changing hash password in phpmyadmin
- WordPress User profile page fields missing
- Disable default posts (Posts,Pages,Comments and Media) in wp-admin
- Trying to use and understand JSON API and get_posts
- Customize a WP_Posts_List_Table class
- User registration add user ID?
- I want to know if it’s good for SEO [closed]
- My website’s wp-admin redirects to another website’s wp-admin after pointing the site url to a subdirectiory
- Help please i cant login to wordpress panel [closed]
- Extend user search in the Wp backend area on the users.php page to allow for searching by email domain and role from the “users search” input box
- Cannot Access wp-admin