you can create conditionnal arguments like that :
$user_args = [
'orderby' => 'display_name',
'order' => 'asc',
'meta_query' => array(
array(
'key' => 'verifier_assign_country',
'value' => $countryCode,
'compare' => '='
),
)
];
if ("" !== $univCode) {
$user_args["meta_query"][] = array(
'key' => 'verifier_assign_univ',
'value' => $univCode,
'compare' => 'LIKE'
);
}
$users = get_users($user_args);
Related Posts:
- Content hooks vs User hooks
- Job of meta_key meta_value fields in database tables
- how to delete all users and posts based on ‘user_meta’?
- get_*_meta doesn’t always return an array
- Like & Dislike functionality using JavaScript
- cannot get user_registered date from get_user_meta
- Display current user’s custom post meta in sidebar
- Show number of posts by logged in user
- Retrieve user_meta and copy to post_meta
- Array of user ids to list of user names
- get Insert id for meta field
- help to decipher wp metadata
- Check For get_post_meta on Author Archive Page
- Sort users by custom user meta value
- Automatically delete inactive users after 2 months
- How we get_post_meta without post id
- What is the code to get the download link for a product in WooCommerce?
- Add a button to users.php
- Adding an assisting editor box to Post page
- include user profiles in search results?
- Plugin that would allow WordPress Authors to “follow” other Authors and query “Activity Info” from that
- Get Advanced Custom Fields values before saving [closed]
- User profile custom field
- Why am I getting an infinite loop with have_posts?
- How to store post meta in an array?
- update_post_meta() not working when used with WordPress action
- Get posts by meta value with date
- Get updated post meta on save_post action?
- Searchable meta value in user.php
- Delete post meta conditionally after save post
- How to store Gutenberg ColourPicker RGBA as metadata
- Is it possible to update a post meta field through REST API if the format of it when registered is nested?
- Unique User Account Number + Displayed Via Shortcode
- trying to do if post meta !=0
- Trying to get file name
- update_user_meta add value on the top on existing value
- how to build (custom) stats for post views, per month
- Removing Post Meta from Category Pages?
- How to get a list of all possible values of a specific user meta key?
- Hey, I want the second options. get_post_meta()
- Update post meta in woocommerce order frontend
- populate post meta in gravity forms [closed]
- Updating wp_user_level on user update
- How to display post view count by date, week and month?
- How can I filter posts when the meta_value is a serialize object?
- Get User Post if Private
- Adding custom class to get_avatar() image doesn&https://wordpress.stackexchange.com/https://wordpress.stackexchange.com/#39;t work
- How to receive all the meta information of a post ?
- How can I attach a user to another user with user meta
- Unknown characters added to meta data values
- Compare old meta with new post meta
- get_post_meta($post->ID) returns empty string when in preview mode of custom post type
- Time & Date on Post – Time Ago Custom Function
- How to pull all the contributer users records and order by Designation (which is users meta data)?
- Mass removing CSS from 1,700 post [closed]
- Reduce number of SQL queries inside WP_Query loop to fetch author data
- Help with Post Meta
- How do I manage custom meta in post revisions in the Block Editor era?
- Generate metadata for cloud images
- Migrating meta value to new meta value
- Insert multiple metas in one time
- How to extract data from a post meta
- count post meta values
- Correct meta of Writing Meta Tags
- Get post_meta from specific post [closed]
- How to add tags to post from frontend?
- Storing user submitted forms [closed]
- Retrieve data from post meta meta_key having ‘_product_fq_image’ while having author_id and post type is PRODUCT
- how do I add role and capability after I create a new user
- getting the post_id from the post_meta
- troubles with get_post_meta (and saving it)
- How to merge the array values in foreach?
- My custom user metadata is only active for only admin but i want it to be active on all users especially customers
- How to get image path from id using SQL
- Update user role for expired membership
- How to exclude posts by meta key value in the_post_navigation next prev links?
- Move Non-WordPress users table to WordPress database
- update_post_meta not working with transition_comment_status
- Store data from JavaScript object to custom table in user account
- Hook into add_user_role and update based on new and removed roles
- How to change the value of a variable using input field?
- Update post meta date always store 1970-01-07
- Is it possible to pass an whole array using custom field in wordpress?
- Attachment metadata has value of ‘1’
- How to update user meta from php file?
- How do I update a specific value within array in a products metadata?
- Autofill advanced custom field with user data
- Programatically delete several attributes in _product_attributes in post meta
- Storing data to database and user registration
- Adding user meta to post meta wp_insert_post() not working
- Get post meta after insert post
- Data not displaying in text field
- WP-API + JS Backbone client – how to update post meta
- Proper Way to Sanitize Meta Input
- update_post_meta returning false when called during init
- Cache metadata for set of posts
- get_post_meta() returns nothing in save_post, publish_post, wp_after_insert_post
- Export user data from Squirrly’s Starbox plugin?
- How to use 2 different databases but share the same user in wordpress
- Add Additional Column in “Users” Dashboard Area – BP Extended Profiles (WordPress)