
@@ -2864,9 +2864,11 @@
  *
  * @param string $user_login Optional. Username to send a password retrieval email for.
  *                           Defaults to `$_POST['user_login']` if not set.
+ * @param string $field Optional. The field to retrieve the user with. id | ID | slug | email | login.
+ *                        Defaults to `login`
  * @return true|WP_Error True when finished, WP_Error object on error.
  */
-function retrieve_password( $user_login = null ) {
+function retrieve_password( $user_login = null, $field = 'login' ) {
 	$errors    = new WP_Error();
 	$user_data = false;
 
@@ -2877,13 +2879,11 @@
 
 	if ( empty( $user_login ) ) {
 		$errors->add( 'empty_username', __( '<strong>Error</strong>: Please enter a username or email address.' ) );
-	} elseif ( strpos( $user_login, '@' ) ) {
-		$user_data = get_user_by( 'email', trim( wp_unslash( $user_login ) ) );
+	} else {
+		$user_data = get_user_by( $field, trim( wp_unslash( $user_login ) ) );
 		if ( empty( $user_data ) ) {
 			$errors->add( 'invalid_email', __( '<strong>Error</strong>: There is no account with that username or email address.' ) );
 		}
-	} else {
-		$user_data = get_user_by( 'login', trim( wp_unslash( $user_login ) ) );
 	}
 
 	/**
