WP_Application_Passwords::delete_application_password() WordPress Method

The WP_Application_Passwords::delete_application_password() method is used to delete an application password for a user. The method takes two parameters: the user ID and the application password to be deleted.

WP_Application_Passwords::delete_application_password( int $user_id, string $uuid ) #

Deletes an application password.


Parameters

$user_id

(int)(Required)User ID.

$uuid

(string)(Required)The password's UUID.


Top ↑

Return

(true|WP_Error) Whether the password was successfully found and deleted, a WP_Error otherwise.


Top ↑

Source

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

	public static function delete_application_password( $user_id, $uuid ) {
		$passwords = static::get_user_application_passwords( $user_id );

		foreach ( $passwords as $key => $item ) {
			if ( $item['uuid'] === $uuid ) {
				unset( $passwords[ $key ] );
				$saved = static::set_user_application_passwords( $user_id, $passwords );

				if ( ! $saved ) {
					return new WP_Error( 'db_error', __( 'Could not delete application password.' ) );
				}

				/**
				 * Fires when an application password is deleted.
				 *
				 * @since 5.6.0
				 *
				 * @param int   $user_id The user ID.
				 * @param array $item    The data about the application password.
				 */
				do_action( 'wp_delete_application_password', $user_id, $item );

				return true;
			}
		}

		return new WP_Error( 'application_password_not_found', __( 'Could not find an application password with that id.' ) );
	}


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.