It looks like you’re using wrong parameters, please try this instead (untested):
$q = new WP_User_Query(
array(
'role' => 'contributor',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'first_meta',
'value' => '2',
),
array(
'key' => 'second_meta',
'value' => '',
'compare' => '!='
)
)
)
);
where we’ve used the key
, value
and compare
parameters within the meta_query
array. I’ve also removed the 'fields' => 'all'
part, because it’s set by default.
Related Posts:
- WP User Query fails when searching meta queries and search columns
- Wp_User_Query not sorting by meta key
- How to add follow functionality to multi-author wordpress site?
- Search multiple meta keys at once
- Plugin that would allow WordPress Authors to “follow” other Authors and query “Activity Info” from that
- How to pull all the contributer users records and order by Designation (which is users meta data)?
- Display the line breaks in user bio without using html
- Getting user data via ajax
- meta_query orderby sort multiple keys
- Sort users by custom user meta value
- Difference between update_user_meta and update_user_option
- get_user_meta() doesn’t include user email?
- List users by last name in WP_User_Query
- How to display custom user meta from registration in backend?
- Allowing an email as the username?
- Grouping users under parent user
- How to create a template for a custom URI associated with the user
- How we can get the user id by its display_name
- How to use hyperdb to separate and share a user dataset between wordpress installs?
- LEFT JOIN, INNER OUTER JOIN, LEFT OUTER JOIN is driving me crazy. Please help?
- \WP_User Object | What’s the Difference Between {caps} and {allcaps}?
- pre_user_query meta_query admin user list
- include user profiles in search results?
- Where to Store Custom User Fields
- Querying Email Addresses for a List of Users with Same Last Name?
- Front end user meta options for users
- delete_user_meta Delete one value out of array
- Drop down list in user profile page
- Searchable meta value in user.php
- How to add country drop down menu to the user profile?
- How to use search_columns in WP_User_Query?
- User Relationship
- Add custom fields to the user profile
- How to query users who have empty first_name?
- stop login if user_status equal zero
- Does wp_delete_user() remove all user content?
- Add user data to table when user is created?
- Updating user meta
- Query users by capability – uninstall/deactivate callback
- How to pass user meta_key and meta_value (values as array)
- Use wp_update_user to update custom column in wp_users table
- Are User Levels Still Currently Used?
- WPML Default Language User Meta [closed]
- WP_User_Query pulling ACF to loop
- Display users in order by an “order” custom meta field
- Search Users base on meta_value & meta_key
- Rest API code to get ID of current user not working: get_current_user_id() gives 0
- how to know when the user is in specific part of the website and when he leaves that part and display the data in the admin dashboard
- User Meta Data in a Sortable Table
- get_user_meta an ID for multiple functions
- WP_User_Query – searching multiple fields
- How can I attach a user to another user with user meta
- Column Sorting Code on users.php
- Creating user without username and password
- Passing args to WP_User_Query am I using meta correctly?
- How to activate the user search
- Is this code true or not
- The Simple and Correct Way to Add User Meta
- Randomize Users
- cannot get user_registered date from get_user_meta
- is_user_logged_in() throwing undefined function error
- Reduce number of SQL queries inside WP_Query loop to fetch author data
- ACF: How to get users with a ACF flexible content subfield with a specific value AND layout?
- last_name + first_name orderby with meta_query [solved]
- how to set default update_user_meta values wordpress
- Get user by meta key – WP multi site
- Cannot Update user meta in custom field
- Can I Create a Second Admin Level User Role?
- Adding fields to the “Add New User” but the form data not saved into DB
- New User Save Filter
- Assigning multiple or additional capabilities to specific users or how to create additional roles like bbpress roles?
- how do I add role and capability after I create a new user
- User Meta stuff
- What does “link” refer to when you delete a user?
- How do I echo all users’ display_name and their meta_value who have a certain meta_key?
- How do I update user email from frontend input field?
- Can I add a unique code for each user based on the location?
- Query users and count totals based on meta values
- 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
- SQL to set Display Name to First Name + Last Name
- Find count of WordPress users by role and search string for user name
- How to do WP_User_Query for Nested Array value Inside Nested Array field
- Hook into add_user_role and update based on new and removed roles
- How to prevent multiple user accounts with the same meta field?
- How to update user meta from php file?
- In admin manage users page, how can I stop users with certain privileges from editing users with other privileges?
- Get meta key with value for user
- user and usermeta table not found
- Require confirmation of current user’s email before updating database and before send_email_change_email
- UserMeta Changes Meta Value for Post ID
- How do I change the user via SQL?
- Username has been exposed
- User list order by user meta
- Problem with update_user_meta() meta_value
- Get all user with both meta_value
- Show only users with the same role in Dashboard user list
- Add custom input field in new user page
- How can I list users by date in an array in meta_value?