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.


Top ↑

Return

(int|WP_Error) The number of passwords that were deleted or a WP_Error on failure.


Top ↑

Source

File: wp-includes/class-wp-application-passwords.php

365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
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;
}


Top ↑

Changelog

Changelog
VersionDescription
5.6.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by the Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.