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
- 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
- Extending WP_User class and using this sub-class during the whole lifecycle
- How we can get the user id by its display_name
- LEFT JOIN, INNER OUTER JOIN, LEFT OUTER JOIN is driving me crazy. Please help?
- Where to Store Custom User Fields
- Querying Email Addresses for a List of Users with Same Last Name?
- ACF Upload Image in front-end with custom form
- delete_user_meta Delete one value out of array
- How to add country drop down menu to the user profile?
- How to use search_columns in WP_User_Query?
- 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?
- How can i create an array user meta?
- Getting users by specific capability, not role
- 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
- 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
- Column Sorting Code on users.php
- Creating user without username and password
- Passing args to WP_User_Query am I using meta correctly?
- Accessing current users data within a plugin
- 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
- Cannot update newly added User field using wp_update_user
- 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
- How can i add user display name drop down menu in frontend?
- 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
- Extend user search in the Wp backend area on the users.php page to allow for searching by email domain and role from the “users search” input box
- Show only users with the same role in Dashboard user list
- Add custom input field in new user page
- WordPress – Security Question at Login from User’s Meta Data
- MySQL query to list users who never signed in
- wp_user_query with meta_value_num for leaderboard
- Buddypress: “Auto load” specific usermeta in WP?
- Add Additional Column in “Users” Dashboard Area – BP Extended Profiles (WordPress)