目录
描述
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.
用法
<?php delete_user_meta( $user_id, $meta_key, $meta_value ) ?>
参数
$user_id
(integer) (必填) user ID
默认值: None
$meta_key
(string) (必填) Metadata name.
默认值: None
$meta_value
(mixed) (可选) Metadata value.
默认值: ''
返回值
示例
1 2 3 4 5 6 7 8 9 |
/* ---------------------------------- * wordpress之魂 © http://wphun.com * ---------------------------------- */ <?php if ( ! delete_user_meta($user_id, '_province') ) { echo "Ooops! Error while deleting this information!"; } ?> |
注意
- 使用到: delete_metadata()
历史
添加于 版本: 3.0
源文件
delete_user_meta() 函数的代码位于 wp-includes/user.php
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
/* ---------------------------------- * wordpress之魂 © http://wphun.com * ---------------------------------- */ /** * 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. * * @since 3.0.0 * @link https://codex.wordpress.org/Function_Reference/delete_user_meta * * @param int $user_id User ID * @param string $meta_key Metadata name. * @param mixed $meta_value Optional. Metadata value. * @return bool True on success, false on failure. */ function delete_user_meta($user_id, $meta_key, $meta_value = '') { return delete_metadata('user', $user_id, $meta_key, $meta_value); } |
- 原文:http://codex.wordpress.org/Function_Reference/delete_user_meta
- 翻译:黄聪@WordPress之魂