Skip to content

Instantly share code, notes, and snippets.

@cryptexvinci
Created January 21, 2022 03:28
Show Gist options
  • Save cryptexvinci/1d9a25b213877ec08bd3a2817eae8b5d to your computer and use it in GitHub Desktop.
Save cryptexvinci/1d9a25b213877ec08bd3a2817eae8b5d to your computer and use it in GitHub Desktop.
Add custom Ultimate member fields Column to Users list table on WordPress
<?php
// Display UM Country Column Label
function um_add_meta_user_table( $column ) {
$column['country'] = 'Country';
return $column;
}
add_filter( 'manage_users_columns', 'um_add_meta_user_table' );
// Display UM Country Column Value
function um_add_meta_user_table_row( $val, $column_name, $user_id ) {
if ($column_name == 'country') {
return get_user_meta( $user_id, 'country', true );
}
return $val;
}
add_filter( 'manage_users_custom_column', 'um_add_meta_user_table_row', 10, 3 );
// Make the Country column sortable
function um_user_sortable_columns( $columns ) {
$columns['country'] = 'country';
return $columns;
}
add_filter( 'manage_users_sortable_columns', 'um_user_sortable_columns' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment