Existing user_meta fields not updated

You can’t change some user meta fields using edit_user_profile_update hook, because it is triggered before processing data from the form. So, you save user’s meta to database, then edit form is processed and WP overrides your values. This hook is triggered after each profile edit. You should use insert_user_meta filter (available since WP v4.4) to … Read more

Updating WooCommerce product field when product author updates profile field

So combined with that code for setting the value before it’s inserted in the db, you also need to add this code to add the post ID to an array stored in the user’s meta (after it has been updated): add_action( ‘wp_insert_post’, ‘smyles_update_user_products’, 10, 3 ); function smyles_update_user_products( $post_ID, $post, $update ) { if ( … Read more

Where do I implement this display of User Meta Data, and how to put it in a table?

If I understood your question correctly, you want to display this data on a page on front-end. In this case you can either create a page template in your theme folder OR create a shortcode in functions.php. Here is a quick shortcode that may help. add_shortcode(‘currentuser’, ‘shortcode_current_user’); function shortcode_current_user($atts){ ob_start(); $current_user = wp_get_current_user(); echo ‘<table>’; … Read more

how to save multiple checkbox in usermeta and get it?

First get the data $data = get_user_meta( $user_id, ‘service_name’, true); You find an array of all entries in $data. You can do it this way: <input type=”checkbox” name=”service_name[]” value=”Architecture” <?php echo in_array(‘Architecture’, $data) ? ‘checked’ : ”); ?>>Architecture<br> Untested, but should work.

Get user by meta data key and velue

This how my stored data function is for this meta group and get data stored $certification = array( ‘course_id’ => $certificate_id, ‘course’ => $certificate, ‘date’ => $date, ‘instructor’ => $certifying_instructor, ‘school’ => $school, ‘last_update’ => date(‘d-m-Y’), ); add_user_meta( $user_ids, ‘certifications’, $certification ); and this get data $users_detail = get_user_meta($user_id); $certificates = $users_detail[‘certifications’]; $n_course_id = array(); … Read more

Get all user meta_keys and then group users by matching values

Eventually came to a solution in case anyone needs it: function mb_get_user_meta_values( $mb_user_meta_key ) { if( empty($mb_user_meta_key) ) return; $mb_get_users = get_users( array( ‘meta_key’ => $mb_user_meta_key ) ); $mb_user_meta_values = array(); foreach( $mb_get_users as $mb_user ) { $mb_user_meta_values[] = get_user_meta( $mb_user->ID, $mb_user_meta_key, true ); } $mb_user_meta_values = array_unique( $mb_user_meta_values ); return $mb_user_meta_values; } Then I … Read more