Custom column named company is added in user table in WordPress. Also sorting functionality of that column is made. However pagination doesn’t show up when the table is sorted with that custom column.
if ('company' == $query->query_vars['orderby']) {
$query->query_fields = 'u.*,um.*,c1.*';
$query->query_from = 'FROM '. $wpdb->prefix.'users as u JOIN '. $wpdb->prefix . 'usermeta as um ON u.ID=um.user_id JOIN ' . $wpdb->prefix . 'company as c1 ON um.meta_value=c1.company_id';
$query->query_orderby = ' ORDER BY company_name ' . ($query->query_vars["order"] == "ASC" ? "asc " : "desc ");
$query->query_limit='LIMIT 20';
}
Also, if we hit the url of page 2 like this
http://example.com/wp-admin/users.php?orderby=company&order=asc&paged=2
it will redirect to
http://example.com/wp-admin/users.php?orderby=company&order=asc&paged=1
I got it
Select only user id not all.
instead of
and change
$query->query_limit=20;