How to set a user meta key value based on another user meta key value

You would need to use a meta query for this. $meta_query_args = array( array( ‘key’ => ‘access_code’, ‘value’ => ‘abc’, ‘compare’ => ‘=’ ) ); $args = array( ‘meta_query’ => $meta_query_args ); $users = get_users( $args ); // User Loop foreach ( $users as $user ) { update_user_meta( $user->ID, ‘association’, ‘XYZ Corporation’); }

get_the_author_meta i want to write in a loop

Your loop rewrite is good so far, yet you can make it better: <?php $at_social_html=”<ul class=”at__social”>”; /* array elements: social-media-name/meta-key => [‘href-before-string’, ‘href-after-string’, ‘fa-class’] */ $author_sociables = array( ‘facebook’ => [”, ”, ‘fa-fb’], ‘twitter’ => [”, ”, ‘fa-twitter’], ‘instagram’ => [”, ”, ‘fa-instagram’], ‘google’ => [‘//plus.google.com/’, ”, ‘fa-google-plus’], ‘pinterest’ => [‘//pinterest.com/’, ”, ‘fa-pinterest’], ‘tumblr’ => … Read more

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

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.

SQL – Shorter way to query user and usermeta data

I was just trying out the wp_get_users() function and I think that’s a much cleaner way to get the user data in a table. I can simply do something like this: $users = get_users(‘role=um_student’); foreach ( $users as $user ) { echo “<tr>”; echo “<td>$user->ID</td>”; echo “<td>$user->user_login</td>”; echo “<td>$user->first_name</td>”; echo “<td>$user->middle_name</td>”; echo “<td>$user->last_name</td>”; echo “<td>$user->university_program</td>”; … Read more

Edit a user profile field on front end

ACF is great for managing user custom fields, but it’s also fairly simple to do what you’re asking using just update_user_meta() to save custom data and then retrieve it with $user->get( ‘whatever’ ); Here’s an example of a form that let’s users set and update their twitter handle: <?php // Grab the current user (Or … Read more

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