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

Set “Display name publicly as” to be usernames by default

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 … Read more

WordPress User Name Limitations

I think the answer is in the source. $username = wp_strip_all_tags( $username ); $username = remove_accents( $username ); // Kill octets $username = preg_replace( ‘|%([a-fA-F0-9][a-fA-F0-9])|’, ”, $username ); $username = preg_replace( ‘/&.+?;/’, ”, $username ); // Kill entities // If strict, reduce to ASCII for max portability. if ( $strict ) $username = preg_replace( ‘|[^a-z0-9 … Read more