WordPress does not allow updating user_login
for existing users. You may update it using $wpdb->update
as below:
// Sanitizes the username
$user_login = sanitize_user( trim( $user_login ), true );
// Check if the given username exists
if ( ! empty( $user_login ) && ! username_exists( $user_login ) ) {
global $wpdb;
//Update user record
$wpdb->update( $wpdb->users, array('user_login' => $user_login), array('ID' => $user_id));
// Delete cached user objects
wp_cache_delete( $user_id, 'users' );
wp_cache_delete( $user_login, 'userlogins' );
}
Related Posts:
- How to remove Biography from user profile admin page
- Integrate WordPress and bbpress profiles?
- Remove Personal Options section from Profile
- Removing “Website” Field from the contact info
- How to disable profile.php for users?
- How to change profile picture in wordpress?
- Replace Gravatar with uploaded images?
- How to create a edit profile page for users?
- How do you make the email field on the profile page read only for subscribers?
- How do I remove the ‘Show Toolbar’ option?
- How to change the link “Edit my profile”?
- remove admin bar show hide option from profile settings
- displaying custom code on a given users profile page
- Make user profile field required
- How to Get User Profile Info on a Category Page
- Best way to change profile page
- The “Profile Picture” section just disappeared from my User Profile
- Fields in User Profile Page
- WP Use Profile Fields is missing
- user-edit.php profile options on TABS
- Using the filters in wordpress theme [closed]
- How display Last modified in profile wordpress [closed]
- Custom Profile Field for
- Add and Remove fields in Profile page
- Removing Fields From the Profile Page of Theme My Login Plugin
- Get WordPress author link by ID
- Add a link back to site on ‘edit profile’ page for users?
- What is the php function for “user’s public profile”
- Replace a specific profile field
- How to change name “Profile”
- Did something change in regards to custom profile fields in WP 4.8.2 (mine have disappeared)?
- Implementing profile page in wordpress
- How to remove unwanted section in profile page for only users?
- allowing user to add content, photos without giving access
- Does WP “out-of-the-box” allow user profile photos? [duplicate]
- Update user from external script
- Renaming profile sections
- Renaming/translating “your profile” page
- get current user password on the profile edit page
- Edit profile fields with TML
- How to create a profile page for users?
- Remove Personal Options section only from subscribers profile
- Disallow user from editing their own profile information
- Extra profile field as select box?
- Allow Profile HTML for select users
- How to create user personal pages with information from their meta profile fields?
- WordPress Rewrite
- Creating distinct pages for author profiles and lists of posts by author
- How to add a checkbox to registration and user profile?
- Author profile visitors in last 7 days in front end without plugins
- Add description text under input field for new profile fields
- Removing WordPress profile fields from non-admins
- Remove /author/ from the author profile url
- AJAX action not triggering PHP function
- Saving custom profile fields
- How to make first_name and last_name required fields in user profile?
- How to upload user profile image from frontend in wordpress ?
- Comments do not respect display_name setting, how to make plugin to overcome this
- How to link to the current User/Author Profile page?
- Is there a way to make custom fields only editable by administrators?
- add custom field in user register form
- Can you use the buddypress profile system without installing the whole of buddypress? [closed]
- Redirecting a buddyboss profile tab to a different tab if not subscribed to a specific membership
- Editable registration date field in user profile
- Can you use another Profile Builder shortcodes through advanced custom fields
- How can I make the user names of commentors clickable links to the user’s profile from the admin comment screen?
- Buddypress export Profile Fields [closed]
- How to Create a User Profile Page?
- Prevent subscribers to changing certain profile fields
- How do I change the image from the default mysteryman in the WP Profile page
- how to connect the author profile with google webmaster tools in multiuser blog?
- How to show all posts by author on buddypress profile with navigation
- How to order custom fields in the user profile (admin area)
- Hide admin notice when user profile updated
- How can I create a profile field group that the user can’t see?
- User can manage one page accessible by everyone?
- Showing user profile data on front-end
- SImple Example To Update User Info From Front End [duplicate]
- Need help with creating a searchable user data by name or specific number like ID
- Get user edit functions in frontend for site admin
- wp_set_password() does not work!
- How can i display pagination in custom comment list?
- profile_update hook does not fire from front-end
- Which membership plugin enables users to enter html links in blogs and on their profile page?
- Using WordPress to create a simple web app (SaaS) [closed]
- want to add video upload option for front end user
- Remove Edit Profile option but still have the profile viewable
- Showing extra profile fields in admin – problem with underscore
- Add an ‘edit profile’ page with Genesis
- Create nonce in frontend page to edit profile
- Multisite – Echo admins profile meta
- Validate user meta and redirect
- Lock Display Name To Nickname
- Storing additional information about the user
- Calling a custom profile field only it it exists
- How ‘secure’ are loops?
- How to create front-end (editable) WordPress user profile pages?
- What techniques can a user employ to achieve a password rated “strong” in the WordPress password checker
- Can we get user profile page using user_id in the URL?
- Issues with creating user profile for a subscriber, but with different profile page and functionalities