Updates user meta field based on user ID.
Use the $prev_value parameter to differentiate between meta fields with the same key and user ID.
If the meta field for the user does not exist, it will be added.
$user_idintrequired
$meta_keystringrequired
$meta_valuemixedrequired
$prev_valuemixedoptional
Default:''
Changes in behavior from the now deprecated update_usermeta:
Update_user_meta does not delete the meta if the new value is empty.
The actions are different.
function update_user_meta( $user_id, $meta_key, $meta_value, $prev_value = '' ) {
return update_metadata( 'user', $user_id, $meta_key, $meta_value, $prev_value );
}
| Version | Description |
|---|---|
| 3.0.0 | Introduced. |
© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/update_user_meta