Skip to content

Instantly share code, notes, and snippets.

@kevinwhoffman
Last active October 19, 2015 02:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevinwhoffman/f99d3f0b9b0bc70cc704 to your computer and use it in GitHub Desktop.
Save kevinwhoffman/f99d3f0b9b0bc70cc704 to your computer and use it in GitHub Desktop.
WP_User_Query with Serialized Array
<?php
// Return users with a single language (English)
$args = array(
'meta_key' => 'wpcf-language-skill',
'meta_value' => 'English'
'meta_compare' => 'LIKE'
);
$user_query = new WP_User_Query( $args );
// Return users with multiple languages (English OR German)
$args = array(
'meta_query' => array(
'relation' => 'OR', // can also be AND if you users must have both languages
$array(
'meta_key' => 'wpcf-language-skill',
'meta_value' => 'English'
'meta_compare' => 'LIKE'
),
$array(
'meta_key' => 'wpcf-language-skill',
'meta_value' => 'German'
'meta_compare' => 'LIKE'
),
)
);
$user_query = new WP_User_Query( $args );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment