I would like for my users to be able to login just by entering their username without password and without 2 factor authentification (no registration possible)
I know it's not good practice, but access to the website will be only possible from a specific location so there is no security issue.
I have found the following code here
// First get the user details
$user = get_user_by('login', $username );
// If no error received, set the WP Cookie
if ( !is_wp_error( $user ) )
{
wp_clear_auth_cookie();
wp_set_current_user ( $user->ID ); // Set the current user detail
wp_set_auth_cookie ( $user->ID ); // Set auth details in cookie
$message = "Logged in successfully";
} else {
$message = "Failed to log in";
}
echo $message;
But i have no idea how and where to implement.
Could i just give everybody the same dummy password and fill it automatically/hidden? Again security is not an issue here, we just want the user to log in to track activity later.