GC_Application_Passwords::delete_all_application_passwords()
最后更新于:2021-11-26 09:13:46
GC_Application_Passwords::delete_all_application_passwords( int$user_id)Deletes all application passwords for the given user.
参数
- $user_id
-
(int) (Required) User ID.
响应
(int|GC_Error) The number of passwords that were deleted or a GC_Error on failure.
源文件
文件: gc-includes/class-gc-application-passwords.php
public static function delete_all_application_passwords( $user_id ) {
$passwords = static::get_user_application_passwords( $user_id );
if ( $passwords ) {
$saved = static::set_user_application_passwords( $user_id, array() );
if ( ! $saved ) {
return new GC_Error( 'db_error', __( 'Could not delete application passwords.' ) );
}
foreach ( $passwords as $item ) {
/** This action is documented in gc-includes/class-gc-application-passwords.php */
do_action( 'gc_delete_application_password', $user_id, $item );
}
return count( $passwords );
}
return 0;
}