WP_Application_Passwords::delete_all_application_passwords() WordPress Method
The WP_Application_Passwords::delete_all_application_passwords() method is used to delete all application passwords for a user. This is useful if a user wants to remove all of their existing application passwords and start fresh.
WP_Application_Passwords::delete_all_application_passwords( int $user_id ) #
Deletes all application passwords for the given user.
Parameters
- $user_id
(int)(Required)User ID.
Return
(int|WP_Error) The number of passwords that were deleted or a WP_Error on failure.
Source
File: wp-includes/class-wp-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 WP_Error( 'db_error', __( 'Could not delete application passwords.' ) );
}
foreach ( $passwords as $item ) {
/** This action is documented in wp-includes/class-wp-application-passwords.php */
do_action( 'wp_delete_application_password', $user_id, $item );
}
return count( $passwords );
}
return 0;
}
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
| Version | Description |
|---|---|
| 5.6.0 | Introduced. |