Skip to content

Instantly share code, notes, and snippets.

@tommcfarlin
Created February 6, 2015 21:17
Show Gist options
  • Save tommcfarlin/3dbbc246e98aa53aab1a to your computer and use it in GitHub Desktop.
Save tommcfarlin/3dbbc246e98aa53aab1a to your computer and use it in GitHub Desktop.
[WordPress] A way to search user meta data without having to use a full word to retrieve results.
<?php
$users = array();
$args = array(
'fields' => 'all_with_meta',
'orderby' => $meta_key,
'meta_query' => array(
array(
'key' => $meta_key,
'value' => $meta_value,
'compare' => 'LIKE'
)
)
);
$user_query = new WP_User_Query($args);
$users = $user_query->get_results();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment