Below is the code I am using to create and make a data sortable column. These data fields are created by Advanced Custom Fields. The dates are not sorting correcting even though they are displayed in a "Ymd" format. Can anyone help me get the dates sorting correctly?
//Add custom column to user list
function new_modify_user_table( $column ) {
$column['school_name'] = 'School Name';
$column['shopping_start_date'] = 'Start Date';
$column['shopping_end_date'] = 'End Date';
return $column;
}
add_filter( 'manage_users_columns', 'new_modify_user_table' );
function new_modify_user_table_row( $val, $column_name, $user_id ) {
switch ($column_name) {
case 'school_name' :
return get_the_author_meta( 'school_name', $user_id );
case 'shopping_start_date' :
return get_the_author_meta( 'shopping_start_date', $user_id );
case 'shopping_end_date' :
return get_the_author_meta( 'shopping_end_date', $user_id );
default:
}
return $val;
}
add_filter( 'manage_users_custom_column', 'new_modify_user_table_row', 10, 3 );
function wpse_user_table_list_sortable_columns($columns) {
$columns['school_name'] = 'school_name';
$columns['shopping_start_date'] = 'shopping_start_date';
$columns['shopping_end_date'] = 'shopping_end_date';
return $columns;
}
add_filter('manage_users_sortable_columns', 'wpse_user_table_list_sortable_columns');