GC_Application_Passwords::get_user_application_passwords()
最后更新于:2021-11-26 09:14:13
GC_Application_Passwords::get_user_application_passwords( int$user_id)Gets a user’s application passwords.
参数
- $user_id
-
(int) (Required) User ID.
响应
(array) The list of app passwords.
源文件
文件: gc-includes/class-gc-application-passwords.php
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'] = gc_generate_uuid4();
$save = true;
}
}
if ( $save ) {
static::set_user_application_passwords( $user_id, $passwords );
}
return $passwords;
}