email_exists

函式
email_exists ( $email )
引數
  • (string) $email The email to check for existence.
    Required:
返回值
  • (int|false) The user ID on success, false on failure.
定義位置
相關方法
domain_existsterm_existstag_existsusername_existsmetadata_exists
引入
2.1.0
棄用
-

email_exists: 這個函式檢查資料庫中的電子郵件地址是否存在。它把電子郵件地址作為唯一的引數,如果電子郵件地址在資料庫中存在,則返回使用者ID,否則返回false。

確定給定的電子郵件是否存在。

關於這個和類似的主題函式的更多資訊,請檢視《主題開發者手冊》中的{@link Conditional Tags}文章。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function email_exists( $email ) {
$user = get_user_by( 'email', $email );
if ( $user ) {
$user_id = $user->ID;
} else {
$user_id = false;
}
/**
* Filters whether the given email exists.
*
* @since 5.6.0
*
* @param int|false $user_id The user ID associated with the email,
* or false if the email does not exist.
* @param string $email The email to check for existence.
*/
return apply_filters( 'email_exists', $user_id, $email );
}
function email_exists( $email ) { $user = get_user_by( 'email', $email ); if ( $user ) { $user_id = $user->ID; } else { $user_id = false; } /** * Filters whether the given email exists. * * @since 5.6.0 * * @param int|false $user_id The user ID associated with the email, * or false if the email does not exist. * @param string $email The email to check for existence. */ return apply_filters( 'email_exists', $user_id, $email ); }
function email_exists( $email ) {
	$user = get_user_by( 'email', $email );
	if ( $user ) {
		$user_id = $user->ID;
	} else {
		$user_id = false;
	}

	/**
	 * Filters whether the given email exists.
	 *
	 * @since 5.6.0
	 *
	 * @param int|false $user_id The user ID associated with the email,
	 *                           or false if the email does not exist.
	 * @param string    $email   The email to check for existence.
	 */
	return apply_filters( 'email_exists', $user_id, $email );
}

常見問題

FAQs
檢視更多 >