Query a meta key using an array of values where the database value is a string

You could use multiple meta clauses in your WP_User_Query, along with a LIKE comparison. Something like $args = array( ‘role’ => ‘member’, ‘meta_query’ => array( ‘relation’ => ‘OR’, array( ‘key’ => ‘specializations’, ‘value’ => ‘doctor’, ‘compare’ => ‘LIKE’, ), array( ‘key’ => ‘specializations’, ‘value’ => ‘researcher’, ‘compare’ => ‘LIKE’, ), ), ); $found_users = new … Read more

wp_mail function not working in user query loop

It’s possible that there’s an issue with your SMTP configuration or with the mailing queue. You can try using a debugging plugin, such as WP Mail Logging, to help diagnose the issue. This plugin logs all emails sent through WordPress and displays them in the admin dashboard, allowing you to see if the emails are … Read more

User Query Multiple Orderby Clause

Try using: ‘orderby’=>’distribution_list last_name’, ‘order’=>’ASC’ Instead of: ‘orderby’ => array( ‘distribution_list’ => ‘ASC’, ‘last_name’ => ‘ASC’, ), So: $users = new WP_User_Query( array( ‘meta_query’ => array( ‘relation’ => ‘AND’, ‘lastname’ => array( ‘key’ => ‘last_name’, ‘compare’ => ‘EXISTS’, ‘type’ => ‘CHAR’, ), ‘list’ => array( ‘distribution_list’ => array( ‘key’ => ‘distribution_list’, ‘value’ => ‘”72″‘, ‘compare’ … Read more

How do I find users by password?

The user password (stored as an MD5 hash) can be retrieved like so: $users = get_users(); foreach ( $users as $user ) { $password = $user->user_pass; } Assuming you have some known value for passkey, you can hash it and compare it to each user’s password: $passkey = ‘somestring’; $hashed_passkey = md5( $passkey ); $users … Read more

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

You can do this more simply by using the pre_get_users hook, grab the search string extract the role from it and add that as a role parameter for WP_User_Query. Edited my original code, here’s a refined version, bit cleaner. Additional edit: Scroll further down for update (see follow-up). class wpse_410251_user_search { private $role = false; … Read more