User query – getting values for custom meta keys/fields

SOLVED. I missed ID field in field array. $args = array( ‘role’ => ‘author’, ‘order’ => ‘DESC’, ‘orderby’ => ‘post_count’, ‘meta_query’ => array( ‘relation’ => ‘OR’, array( ‘key’ => ‘medical_diagnosis’, ‘compare’ => ‘EXISTS’, ), array( ‘key’ =’gender’, ‘compare’ => ‘EXISTS’, ), ), ‘who’ => ‘authors’, ‘count_total’ => true, ‘fields’ => array( ‘ID’, ‘user_email’, ‘display_name’), ); … Read more

Is it possible to use WP_USER_QUERY to search by username using a wildcard? [closed]

I found the following class in the add user autocomplete plugin . It extends the normal searcha and allows ‘*’; Example: $wp_user_search = new A2B_User_Query( array( ‘search’ => $s . ‘*’ ) ) ; class A2B_User_Query extends WP_User_Query { /** * @see WP_User_Query::get_search_sql() */ function get_search_sql( $string, $cols, $wild = false ) { $string = … Read more

Listing wordpress users with a search function

This worked for me. $user_query = new WP_User_Query( array( ‘search’ => ‘*example.net*’, ‘search_columns’ => array(‘user_url’) )); $authors = $user_query->get_results(); The wild card to be used in the search string is ‘*’ and not ‘%’. Also you have to include the ‘search_columns’ parameter with the following possible values search_columns = array( ‘user_nicename’, ‘user_login’, ‘user_email’, ‘user_url’ ) … Read more

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