Register email as username

Emails can not be used as user names as wordpress uses user names by default as part of urls (for example the author page). Therefor it is not enough to let users register with email addresses, you also need to have some code to handler the URL related issues. Anyway this sounds like an XY … Read more

How to change a username?

Answer originally posted on another question which was more “why we can’t” instead of “how”: https://web.archive.org/web/20210408084000/https://wordpress.stackexchange.com/questions/135304/why-cant-i-update-username-through-wordpress-api/386265 Here is the solution I used to change the username properly (based on https://www.wpbeginner.com/wp-tutorials/how-to-change-your-wordpress-username/ which had missing information): I was able to change the username simply with SQL using update wp_users set user_login = “old_username”, user_nicename = “new_username” where … Read more

How to translate “ERROR: Invalid username. Lost your password?”

In the en_GB version of the .mo translation file, this string is available: <strong>ERROR</strong>: Invalid username. <a href=\”%s\” title=\”Password Lost and Found\”>Lost your password</a>? and the reference is from wp-includes/user.php on line 93. I found this using Poedit and searching using Ctrl + F. From line 93 we get the following code: return new WP_Error( … Read more

One time username change from frontend?

Just add a meta record that tracks the state of the username-changing actions: $user = wp_get_current_user(); $did_one_change = get_user_meta($user->ID, ‘changed_username’, true); if($did_one_change !== false) wp_die(‘You already changed your user name once!’); wp_update_user(array( ‘ID’ => $user->ID, ‘first_name’ => $_POST[‘first_name’], ‘last_name’ => $_POST[‘last_name’], )); // here add a meta entry that suggests the user has changed their … Read more

How to override WordPress registration and insert an auto-generated username?

One alternative is to modify the $_POST[‘user_login’] input value when submitting new registration form, that is before WP process the registration form. A good hook to achieve this is login_form_register that fires before processing and rendering registration form. login_init also works but need more work to make sure we are on register action. add_action(‘login_form_register’, ‘custom_user_login’); … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)