Page 1 of 1

how to list custom registration fields from ALL users?

PostPosted: July 29th, 2011, 9:50 pm
by nusatsum
I have a business directory.

Subscribers have custom registration fields where they can specify the information about their business and manage it in their profile.

I would like to generate a list of all subscriber's business_title's for example.

Where should I begin?

I have looked into get_users (wordpress) but it doesn't return the custom registration fields.

S2member's S2MEMBER_CURRENT_USER_FIELDS is only for the current user. How would I get this for all users that fit a particular criteria (in my case role=subscriber).

Any help would be appreciated.

Re: how to list custom registration fields from ALL users?

PostPosted: July 30th, 2011, 9:44 pm
by Cristián Lávaque
This thread may help you viewtopic.php?f=4&t=10414

Re: how to list custom registration fields from ALL users?

PostPosted: August 1st, 2011, 12:44 pm
by nusatsum
Thanks Cristián but after a couple of hair pulling days I must admit I'm not getting anywhere. Over in another thread (http://www.primothemes.com/forums/viewtopic.php?f=4&t=6217 ) you recommended using custom registration fields to implement a business directory. I realize now I would have to spend a lot of time understanding the underlying frameworks in order to use this approach. Unless someone could help with a code snippet?

All I need is to list the custom fields for all users in a loop.

Pretty please? :P

Re: how to list custom registration fields from ALL users?

PostPosted: August 1st, 2011, 9:56 pm
by Cristián Lávaque
There isn't a straightforward way to do that yet. You can't just query the database based on that custom field because s2Member custom fields are currently saved in an associative array.

You'd have to load the custom fields for every member, put them in an associative array with the custom field as the key so you can sort the array by it, and then loop it.

Or something of the sort depending on the exact use you want. I don't have time to develop it at this moment, but a freelance developer should be able to do it for you.

Re: how to list custom registration fields from ALL users?

PostPosted: August 1st, 2011, 11:40 pm
by nusatsum
I see. Thanks for filling me in. I did purchase a pro license. I would have no problem coding what you suggested if only I understood s2member a little better. For example, how would I get the custom user profile fields by user ID when all the functions are intended for the current user? Is there a built-in facility to do this? I appreciate your assistance.

Re: how to list custom registration fields from ALL users?

PostPosted: August 2nd, 2011, 1:27 am
by Cristián Lávaque
Code: Select all
$s2_custom_fields get_user_option('wp_s2member_custom_fields'$user_id); 


:)

Re: how to list custom registration fields from ALL users?

PostPosted: August 2nd, 2011, 2:27 am
by nusatsum
Thank you!

Re: how to list custom registration fields from ALL users?

PostPosted: August 2nd, 2011, 10:52 pm
by Cristián Lávaque
;)