I need to update a single column in wordpress wp_usermeta
.I have gone through the web and I found these codes
<?php update_user_meta( $user_id, $meta_key, $meta_value, $prev_value ); ?>
Here
user_id=1, meta_key=first_name, meta_value="Smith", $prev_value="benny"
How do i write SQL to update the specific column.
You don't need to write the SQL, wp gives you that function.
If you are doing a one-off to update the DB, then in your phpmyadmin, you just find the record, and edit it manually;
if writing PHP, then you use
update_user_meta( $user_id, $meta_key, $meta_value, $prev_value )
ie update_user_meta( 1, 'first_name', 'Smith', 'benny' )
Use below code to update user meta value if it match old meta value
$user_id = 1;
$meta_key = 'first_name';
$new_value = 'Smith';
$prev_value = 'benny';
update_user_meta( $user_id, $meta_key, $new_value, $prev_value );