WP_Application_Passwords::get_user_application_passwords()public staticWP 5.6.0

Gets a user's application passwords.

Метод класса: WP_Application_Passwords{}

Хуков нет.

Возвращает

Массив. The list of app passwords.

Использование

$result = WP_Application_Passwords::get_user_application_passwords( $user_id );
$user_id(int) (обязательный)
User ID.

Список изменений

С версии 5.6.0 Введена.

Код WP_Application_Passwords::get_user_application_passwords() WP 6.6.2

public static function get_user_application_passwords( $user_id ) {
	$passwords = get_user_meta( $user_id, static::USERMETA_KEY_APPLICATION_PASSWORDS, true );

	if ( ! is_array( $passwords ) ) {
		return array();
	}

	$save = false;

	foreach ( $passwords as $i => $password ) {
		if ( ! isset( $password['uuid'] ) ) {
			$passwords[ $i ]['uuid'] = wp_generate_uuid4();
			$save                    = true;
		}
	}

	if ( $save ) {
		static::set_user_application_passwords( $user_id, $passwords );
	}

	return $passwords;
}