The "update_user_meta" function in WordPress is used to update a specific meta field for a user in the database. This function is particularly useful if you want to store additional information or data about a user beyond the standard WordPress user fields.
The function takes three parameters:
- User ID – the ID of the user whose meta field you want to update.
- Meta key – the name of the meta field you want to update.
- Meta value – the new value for the meta field.
Here’s an example usage code:
$user_id = 25; $meta_key = 'favorite_color'; $meta_value = 'blue'; update_user_meta( $user_id, $meta_key, $meta_value );
In this example, we’re updating the "favorite_color" meta field for the user with an ID of 25, and setting the value to "blue". This would update the value of the "favorite_color" meta field in the database for that user.
Overall, the "update_user_meta" function is a powerful tool for customizing and extending the user capabilities of WordPress.