delete_user_meta()WP 3.0.0

Deletes the specified meta-data of a certain user.

You can specify the option for deletion by key ($meta_key) or simultaneously by key and value of the key ($meta_key, $meta_value). Deletion by key and value protects against deleting duplicate options that have the same keys. If only the key is specified, all options with the specified key will be deleted (there may be several).

User meta-data is analogous to custom fields in posts. Here, however, the post is a user. Such data is stored in the table wp_usermeta.

No Hooks.

Returns

true|false. true or false, depending on whether the deletion was successful or not.

Usage

delete_user_meta( $user_id, $meta_key, $meta_value );
$user_id(integer) (required)
User ID.
$meta_key(string) (required)
Name of the option to be deleted.
$meta_value(string)
Value of the option to be deleted. Works in conjunction with the $meta_key parameter.
Default: ''

Examples

7

#1 Delete option _province from user 9:

$user_id = 9;
if ( ! delete_user_meta( $user_id, '_province' ) ) {
	echo "Oooops! A mistake happened during this operation!";
}

Changelog

Since 3.0.0 Introduced.

delete_user_meta() code WP 6.9

function delete_user_meta( $user_id, $meta_key, $meta_value = '' ) {
	return delete_metadata( 'user', $user_id, $meta_key, $meta_value );
}