WordPress.org

Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/delete user meta

Description

Remove metadata matching criteria from a user.

You can match based on the key, or key and value. Removing based on key and value, will keep from removing duplicate metadata with the same key. It also allows removing all metadata matching key, if needed.

Usage

<?php delete_user_meta$user_id$meta_key$meta_value ?>

Parameters

$user_id
(integer) (required) user ID
Default: None
$meta_key
(string) (required) Metadata name.
Default: None
$meta_value
(mixed) (optional) Metadata value.
Default: ''

Return Values

(boolean) 
False for failure. True for success.

Examples

This example will delete the meta_key is 'disabled' for user id 9.

 
<?php 
$user_id = 9;
delete_user_meta($user_id, 'disabled');
?>

Using if condition

<?php
if ( ! delete_user_meta($user_id, '_province') ) {
  echo "Ooops! Error while deleting this information!";
}
?>

Notes

Change Log

Since: 3.0

Source File

delete_user_meta() is located in wp-includes/user.php.

Related

add_user_meta(), delete_user_meta(), get_user_meta(), update_user_meta(), get_user_option(), delete_user_option(), update_user_option(),

See also index of Function Reference and index of Template Tags.