Support » Plugins » Hacks » How to Search Users by custom meta value

  • dscouron


    Running into problems trying to search/filter user information to display a desired result. What I’m trying to accomplish is that if a custom key value on the current page equals a custom field in the user profile, then do something. To give an example:

    I’ve added corresponding custom fields to the user profile page and custom keys when creating pages. A new user signs up and inserts “Chicago” into the custom field labeled “city”, which is defined as user_city. On each new page I create, I can give a value to the custom key labeled “page_city”, which in this case I would also enter “Chicago”. Now what I want to do is to search through all users and compare the custom user_city to the page_city of the current page. I’ve started the process by including:

    $current_page_city = get_post_meta($post->ID, 'page_city', true);

    But I can’t find any successful way to search through the user meta value to see if it matches. I originally tried the_author_meta('user_city'); but that only returns my ‘user_city’ since i’m creating the page itself. Need a way to search all users, no just authors…

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘How to Search Users by custom meta value’ is closed to new replies.