wp_is_application_passwords_available_for_user

函式
wp_is_application_passwords_available_for_user ( $user )

wp_is_application_passwords_available_for_user: 這個函式用來檢查應用密碼是否對某個特定的使用者可用。它接受一個使用者ID作為引數,並檢查該使用者是否具有使用應用程式密碼的必要許可權。

檢查應用程式密碼是否對特定使用者可用。

預設情況下,所有使用者都可以使用應用密碼。使用{@see ‘wp_is_application_passwords_available_for_user’}來限制對特定使用者的可用性。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function wp_is_application_passwords_available_for_user( $user ) {
if ( ! wp_is_application_passwords_available() ) {
return false;
}
if ( ! is_object( $user ) ) {
$user = get_userdata( $user );
}
if ( ! $user || ! $user->exists() ) {
return false;
}
/**
* Filters whether Application Passwords is available for a specific user.
*
* @since 5.6.0
*
* @param bool $available True if available, false otherwise.
* @param WP_User $user The user to check.
*/
return apply_filters( 'wp_is_application_passwords_available_for_user', true, $user );
}
function wp_is_application_passwords_available_for_user( $user ) { if ( ! wp_is_application_passwords_available() ) { return false; } if ( ! is_object( $user ) ) { $user = get_userdata( $user ); } if ( ! $user || ! $user->exists() ) { return false; } /** * Filters whether Application Passwords is available for a specific user. * * @since 5.6.0 * * @param bool $available True if available, false otherwise. * @param WP_User $user The user to check. */ return apply_filters( 'wp_is_application_passwords_available_for_user', true, $user ); }
function wp_is_application_passwords_available_for_user( $user ) {
	if ( ! wp_is_application_passwords_available() ) {
		return false;
	}

	if ( ! is_object( $user ) ) {
		$user = get_userdata( $user );
	}

	if ( ! $user || ! $user->exists() ) {
		return false;
	}

	/**
	 * Filters whether Application Passwords is available for a specific user.
	 *
	 * @since 5.6.0
	 *
	 * @param bool    $available True if available, false otherwise.
	 * @param WP_User $user      The user to check.
	 */
	return apply_filters( 'wp_is_application_passwords_available_for_user', true, $user );
}

常見問題

FAQs
檢視更多 >