Wp_user_query search by meta_key not returning any results

You’re setting two different meta_key fields to check on: ‘course’, and ‘clinic’. Try doing it with just one like so: $args = array( ‘orderby’ => ‘display_name’, ‘fields’ => ‘all’, ‘search’ => $search, ‘meta_query’ => array( array( ‘key’ => ‘clinic’, ‘value’ => $search, ‘compare’ => ‘LIKE’ ) ) ); What your current query is doing is … Read more

WP_User_Query with 2 sets of conditions ‘AND’

You have an example here: https://codex.wordpress.org/Class_Reference/WP_User_Query#Custom_Field_Parameters Problem with your query is that you use wrong keys. It should be: $args = array ( ‘meta_query’ => array( ‘relation’ => ‘AND’, array( ‘key’ => $campaign_type, ‘value’ => $Campaign_ID, ‘compare’ => ‘=’ ), array( ‘key’ => ‘organisation’, ‘value’ => $userOrg, ‘compare’ => ‘=’ ) )); Longer versions (meta_key, … Read more

custom post type ‘pre_[cpt]_query’ hook

WP doesn’t provide (as far as I remember) hooks specific to CPTs. There are a lot of hooks in WP_Query class to bend the post queries different ways. In most cases they are passed the query object itself, which is used to derive the context (such as is query for specific post type).

WP_User_Query Filter Results

Mostly a PHP question but if I understand your question, you want something like this: $args = array( ‘role’ => ‘talent’, ‘order’ => ‘DESC’, ‘orderby’ => ‘user_registered’, ‘meta_key’ => ‘position’, ‘number’ => ’15’ ); $meta = array ( array( ‘key’ => ‘picture’, ‘value’ => array(”), ‘compare’ => ‘NOT IN’ ), array( ‘key’ => ‘position’, ‘value’ … Read more