Title: Filter Function based on Author Meta Field Values
Last modified: August 21, 2016

---

# Filter Function based on Author Meta Field Values

 *  [designerfosh](https://wordpress.org/support/users/designerfosh/)
 * (@designerfosh)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/filter-function-based-on-author-meta-field-values/)
 * I have a custom field with radio boxes added to my WP Authors Profile. I am also
   using a wp contributors function to display all the authors. I would like to 
   filter the authors this function displays based on whether or not the custom 
   radio box is checked yes or no.
 * Any help is appreciated!
 * Contributors Function
    [http://www.wpbeginner.com/wp-tutorials/how-to-display-an-author-list-with-avatars-in-wordpress-contributors-page/](http://www.wpbeginner.com/wp-tutorials/how-to-display-an-author-list-with-avatars-in-wordpress-contributors-page/)
 * Custom user field
    $featauth = get_the_author_meta( ‘featauth’, $user->ID);

Viewing 1 replies (of 1 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/filter-function-based-on-author-meta-field-values/#post-4511910)
 * The easy solution would be to wrap all the echo statements inside a conditional
   which checks that the author meta value is yes before echoing out the content.
   With a lot of authors, this would get very inefficient, a separate SQL query 
   for every author.
 * A better solution would be to alter the `get_results()` query to only return 
   authors that have the yes meta value in the first place. This involves joining
   in the usermeta table in order for the query to check for the correct values.
   While this is a somewhat straight forward query, I don’t know exactly how to 
   write it without some research and trials of my own. Unless someone else here
   can contribute, you’re on your own with this one.
 * An equivalent approach which may be easier to code (especially if you are familiar
   with WP_Query) would be to use a [WP_User_Query](http://codex.wordpress.org/Class_Reference/WP_User_Query)
   to form and execute the query. It does include meta query capabilities. You end
   up with the same array of author/user objects, but you are spared mySQL syntax
   in favor of PHP and WP query syntax. Pick your poison 🙂
 * The last one I could help you on if need be, except I will have sporadic Internet
   access for the next week or so. Response time could be a few days.

Viewing 1 replies (of 1 total)

The topic ‘Filter Function based on Author Meta Field Values’ is closed to new replies.

## Tags

 * [function](https://wordpress.org/support/topic-tag/function/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 1 reply
 * 2 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [12 years, 5 months ago](https://wordpress.org/support/topic/filter-function-based-on-author-meta-field-values/#post-4511910)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
