I want to add custom filter with a custom column from users table not a metaKey. I find this function to filter by a metaKey:
add_filter('pre_get_users', 'filter_users_by_job_role_section');
function filter_users_by_job_role_section($query)
{
global $pagenow;
if (is_admin() && 'users.php' == $pagenow) {
// figure out which button was clicked. The $which in filter_by_job_role()
$top = $_GET['job_role_top'];
$bottom = $_GET['job_role_bottom'];
if (!empty($top) OR !empty($bottom))
{
$section = !empty($top) ? $top : $bottom;
// change the meta query based on which option was chosen
$meta_query = array (array (
'key' => 'membership_user_role',
'value' => $section,
'compare' => 'LIKE'
));
$query->set('meta_query', $meta_query);
}
}
}
I want to change the query to use a comumn table "user_status". How can I do it please.