Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Display email address instead of the user_login when user is already logged in
<?php
add_filter( 'wp_login_errors', function( $errors ){
$GLOBALS['hb_backup_user_login'] = null;
if ( ! empty( $GLOBALS['user_login'] ) && empty( $_POST['log'] ) ) {
$GLOBALS['hb_backup_user_login'] = $GLOBALS['user_login'];
$GLOBALS['user_login'] = wp_get_current_user()->user_email;
}
return $errors;
});
add_action( 'login_form', function(){
if ( ! is_null( $GLOBALS['hb_backup_user_login'] ) ) {
$GLOBALS['user_login'] = $GLOBALS['hb_backup_user_login'];
$GLOBALS['hb_backup_user_login'] = null;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment