update_user_meta() not working

wp_get_current_user() returns an object. update_user_meta( $user_id, $meta_key, $meta_value, $prev_value ) accepts user_id as first parameter. Use the following code to get user ID from wp_get_current_user() update_user_meta( $user->ID, ‘custom_user_fields’, $userData );

Assign second role to user

If you first fetch a WP_User object with get_userdata(), you should then be able to add your additional role with the add_role() method, like so: $user = get_userdata($user_id); $user->add_role(‘partner’);

How to edit custom user meta information front end

I have solved it. In the redirect I changed if (count($error) == 0 ){ to if (count($error) < 1 ){ Also for any custom user meta fields added duplicated the following line and change the word ‘description’ to the name of the field create in your function file. if ( !empty( $_POST[‘description’] ) ) update_user_meta( … Read more

Set meta_key and meta_value for all registered user in wordpress using sql query [closed]

Add this code in functions.php. visit your site you, it will automatic add/update all user meta value. After executing this code just comment out or remove this code. $args = array( ‘fields’ => ‘all’, ); $blogusers = get_users( $args); foreach($blogusers as $key => $user){ update_user_meta( $user->ID, ‘is_activated’, 1 ); } OR you can also do … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)