Last active
April 16, 2021 06:44
-
-
Save champsupertramp/cb43f0d079b9160cd13238c75dd76257 to your computer and use it in GitHub Desktop.
Ultimate Member - UM Custom user query in Member Directory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Show users with a Job Title "'WP Plugin developer " only | |
**/ | |
add_filter('um_prepare_user_query_args', 'um_my_custom_query_args', 99, 2); | |
function um_my_custom_query_args( $query_args, $args ) { | |
if( $args["form_id"] == "1" ) { // you can validate the current member directory form ID | |
$query_args['meta_query'][] = array( | |
"relation" => "OR", | |
array( | |
'key' => 'job_title', | |
'value' => serialize( 'WP Plugin developer' ), | |
'compare' => 'LIKE' | |
), | |
array( | |
'key' => 'job_title', | |
'value' => 'WP Plugin developer', | |
'compare' => '=' | |
) | |
); | |
} // endif | |
return $query_args; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Everyone,
I'll be sharing some Ultimate Member customizations & tutorials on my website: www.champ.ninja
Subscribe to my newsletter to get the latest tutorials.
Regards,