How to make a custom column on the Users admin screen sortable?

This is my code which adds a sortable custom column (called Vendor ID) to the users table: function fc_new_modify_user_table( $column ) { $column[‘vendor_id’] = ‘Vendor ID’; return $column; } add_filter( ‘manage_users_columns’, ‘fc_new_modify_user_table’ ); function fc_new_modify_user_table_row( $val, $column_name, $user_id ) { switch ($column_name) { case ‘vendor_id’ : return get_the_author_meta( ‘vendor_id’, $user_id ); default: } return $val; … Read more

Add default WordPress tag meta box to User Profile

This code works for me. It uses ‘locations’ custom taxonomy and ‘suggest’ javascript. You need to extend it to support multiple term selection. Add custom field to user-edit screen and store metadata when user/admin updates profile // for account owner add_action(‘show_user_profile’, ‘add_custom_user_profile_fields’); add_action(‘personal_options_update’, ‘save_custom_user_profile_fields’); // for admins add_action(‘edit_user_profile’, ‘add_custom_user_profile_fields’); add_action(‘edit_user_profile_update’, ‘save_custom_user_profile_fields’); function add_custom_user_profile_fields($user) { printf( … Read more

How do you update user_email on the front end in WP 3.3?

You need to use wp_update_user() for the email, as it is not user-meta but core user data. The code should look something like this: $args = array( ‘ID’ => $current_user->id, ‘user_email’ => esc_attr( $_POST[‘user_email’] ) ); wp_update_user( $args ); Note: that’s untested, but it should work out of the box.

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.

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