get_user_meta() doesn’t include user email?

get_user_meta retrieves a single meta field or all fields of the user_meta data for the given user. This means that all the values that are stored in user_meta table can be got using get_user_meta. Email is not stored as meta data so you cant get email using get_user_meta. Email is stored with username and password … Read more

How to filter users on admin users page by custom meta field?

UPDATE 2018-06-28 While the code below mostly works fine, here is a rewrite of the code for WP >=4.6.0 (using PHP 7): function add_course_section_filter( $which ) { // create sprintf templates for <select> and <option>s $st=”<select name=”course_section_%s” style=”float:none;”><option value=””>%s</option>%s</select>”; $ot=”<option value=”%s” %s>Section %s</option>”; // determine which filter button was clicked, if any and set section … Read more

add_user_meta() vs update_user_meta()

You have already found out that using update_user_meta() if the meta field for the user does not exist, it will be added. ie update_user_meta() can do the task of add_user_meta() However, the difference between them is the return values update_user_meta() returns False if no change was made (if the new value was the same as … Read more

Difference between update_user_meta and update_user_option

In layman terms there is no major difference! update_user_option() uses update_user_meta() internally. The only difference is update_user_option() prefix the option name with database table prefix + blog ID if you are in multisite and just table prefix if you are in single site installation. Take a look at the code of update_user_option() /** * Update … Read more

Adding fields to the “Add New User” screen in the dashboard

user_new_form is the hook that can do the magic here. function custom_user_profile_fields($user){ ?> <h3>Extra profile information</h3> <table class=”form-table”> <tr> <th><label for=”company”>Company Name</label></th> <td> <input type=”text” class=”regular-text” name=”company” value=”<?php echo esc_attr( get_the_author_meta( ‘company’, $user->ID ) ); ?>” id=”company” /><br /> <span class=”description”>Where are you?</span> </td> </tr> </table> <?php } add_action( ‘show_user_profile’, ‘custom_user_profile_fields’ ); add_action( ‘edit_user_profile’, ‘custom_user_profile_fields’ … Read more

how to get list of all users and their metadata

I think you should use wp-api functions which will do everything for you. get_users() function will get all users data just define fields which u require. get_user_meta() function will get usermeta data. $users = get_users( array( ‘fields’ => array( ‘ID’ ) ) ); foreach($users as $user){ print_r(get_user_meta ( $user->ID)); }

How to get a buddypress user profile link and a certain user profile field for the current post author?

For an author’s profile link, use bp_core_get_user_domain( $user_id ) to get the URL, and bp_core_get_userlink( $user_id ) to get an HTML link element, including display name. For the xprofile data, use xprofile_get_field_data( $field, $user_id ) $field can be either the name of the field (like ‘Biography’) or the numerical field id.

user_login vs. user_nicename

user_nicename is url sanitized version of user_login. In general, if you don’t use any special characters in your login, then your nicename will always be the same as login. But if you enter email address in the login field during registration, then you will see the difference. For instance, if your login is [email protected] then … Read more