Want to add my custom prepare query but add_filter doesn’t run

The WP_User_Query allows meta_query searches exactly like the other WP_*_Query classes. Example here: global $wpdb; $author_search = new WP_User_Query( array( ‘role’ => ‘subscriber’, ‘fields’ => ‘all_with_meta’, // if it’s a digit/int/float, use ‘meta_value_num’ ‘orderby’ => ‘meta_value’, ‘order’ => ‘ASC’, // you could try -1 as well. ‘nuber’ => 99999999, ‘meta_query’ => array( ‘key’ => ‘my_userpoints’, … Read more

Searching users with WP_List_Table plugin

Brian is correct. By changing the form to use get instead of post and then using $_REQUEST to fetch it should work, and is for me. // Fetch, prepare, sort, and filter our data. if( isset( $_REQUEST [“s”] ) ){ // Form that displays the table and also contains the search_box() <form id=”table-class-filter” method=”get” class=”table-class-admin-form”>

User appears twice in a WP_User_Query

Try this for kicks… Solution 1 Note: Does not work with WP_User_Query (?) add_filter(‘posts_distinct’, ‘user_meta_query_distinct’); //your query here… remove_filter(‘posts_distinct’, ‘user_meta_query_distinct’); function user_meta_query_distinct() { return “DISTINCT”; } Solution 2 Can you try adding ‘relation’ => ‘OR’ to your meta_query: $user_query = new WP_User_Query( array( ‘role’ => ‘member’, ‘orderby’ => ‘registered’, ‘order’ => ‘DESC’, ‘meta_query’ => array( … Read more

How to order WP_User_Query results to match the order of an array of user IDs?

Updated: The WP_User_Query class, in WordPress 4.1+, supports it with : ‘orderby’ => ‘include’ Since WordPress 4.7 there’s also support for: ‘orderby’ => ‘login__in’ and ‘orderby’ => ‘nicename__in’ So we no longer need to implement it through a filter, like we did here below. Previous Answer: I wonder if this works for you: add_action( ‘pre_user_query’, … Read more

WP_User_Query users by registered date

You can simply use the date_query parameter on the user registration date: $args = array ( ‘role’ => ‘subscriber’, ‘date_query’ => array( array( ‘after’ => ‘2010-01-13 00:00:00’, ‘inclusive’ => true, ), ), ); $user_query = new WP_User_Query( $args ); This part of the WP_User_Query source code, makes it possible: // Date queries are allowed for … Read more

How to search display_name column when using WP_User_Query

You can try this: /** * Add support for the “display_name” search column in WP_User_Query * * @see http://wordpress.stackexchange.com/a/166369/26350 */ add_filter( ‘user_search_columns’, function( $search_columns ) { $search_columns[] = ‘display_name’; return $search_columns; } ); where we use the user_search_columns filter to modify the available search columns. So what fields can we use with this filter? Here’s … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)