Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

WP_User_Query – search for a particular user

We’re going to pass the $username to this query, so this will work without the quotes around $username.

// WP_User_Query arguments
$args = array(
	'search'         => '$username',
	'search_columns' => array( 'user_login' ),
	'number'         => '1',
	'fields'         => 'all',
);

// The User Query
$user_query = new WP_User_Query( $args );