Using WP_User_Query on Pods fields
-
After coming across your tutorial at https://docs.pods.io/tutorials/creating-user-directory/step-5-creating-a-list-of-users-and-profile-page/ I decided to follow that and extend the User type rather than create a custom post type. Thanks for that tutorial, it was very helpful.
For the page I’m working on, I want to be able to select a subset of users, based on a Pod field of Company, which is a related field, to a custom category.
I tried the following code but I get No users found.
$users = new WP_User_Query(array(
‘meta_key’=>’_pods_company’,
‘meta_value’ => ‘C1’,
‘orderby’=>’meta_value’,
‘fields’=>’all_with_meta’
));I tried first using ‘company’ for the meta_key, but after that didn’t work, I looked in the database and saw it listed as _pods_company. The tutorial doesn’t provide an example so I’m not sure how to select the records based on Pods field.
I tried using last_name for meta_key and a valid last name for meta_value and that worked ok. So I’m not sure if I need to do something different if I wan’t to search for a Pods field?
I tried searching the forum for WP_User_Query and came up empty
The page I need help with: [log in to see the link]
- The topic ‘Using WP_User_Query on Pods fields’ is closed to new replies.