WP_Application_Passwords::delete_all_application_passwords( int $user_id ): int|WP_Error

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. View all references

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 ↑

Hooks



Top ↑

Changelog

Changelog
Version Description
5.6.0 Introduced.

Top ↑

User Contributed Notes

You must log in before being able to contribute a note or feedback.