I want to extend my view of users list by:
- adding sortable column based on custom field
- giving possibility of filtering list by custom field
So what i've did:
- created custom field via ACF (its name is: opiekun_klienta)
- entered proper values via user settings (so i've picked one of the values from the list)
I have such a piece of code:
add_filter( 'manage_users_columns', 'column_register_wpse_101322' );
add_filter( 'manage_users_custom_column', 'column_display_wpse_101322', 10, 3 );
function column_register_wpse_101322( $columns )
{
$columns['accountmanager_col'] = 'Opiekun';
return $columns;
}
function column_display_wpse_101322( $empty, $column_name, $opiekunklienta )
{
$opiekunklienta = get_field( "opiekun_klienta" );
if ( 'accountmanager_col' != $column_name )
return $empty;
return "<strong>$opiekunklienta</strong>";
the code adds column but there are no values displayed. Where is the mistake in the code? i cannot find it.. on top of that I would like to create a dropdown+submit button to filter the list in general (so the dropdown will display values of the custom field. I have no clue where to start with it..
thanks for any tips!
Updated Code:
add_filter( 'manage_users_columns', 'column_register_wpse_101322' );
add_filter( 'manage_users_custom_column', 'column_display_wpse_101322', 10, 3 );