I’m using the manage_users_columns to display a custom field I create in the usermeta database called company. My code is as follows:
function mysite_column_company( $defaults ) {
$defaults['mysite-usercolumn-company'] = __('Company', 'user-column');
return $defaults;
}
function mysite_custom_column_company($value, $column_name, $id) {
if( $column_name == 'mysite-usercolumn-company' ) {
return get_usermeta($id, 'company');
}
}
add_action('manage_users_custom_column', 'mysite_custom_column_company', 15, 3);
add_filter('manage_users_columns', 'mysite_column_company', 15, 1);
I’d like to get to display two other custom fields, but can’t figure out the proper function. Duplicating this one doesn’t work and I’ve not had any luck adding new functions within this one for each unique column, mostly because I can’t seem to figure out how to properly define the $defaults variable. Any suggestions?
hummm… do you mean something like this :
by the way, you should use get_the_author_meta() instead of get_usermeta() as it is deprecated.