If you want to grab multiple xprofile fields from all members, the best way at the moment to accomplish this is to use a direct DB query.
I was going to recommend the members loop, but you need specific xprofile fields.
If it’s just first and last names for your drop down – you can fetch those from the default WordPress fields / calls.
Is ‘role’ stored as an xprofile field or are you mapping across to WordPress roles? If the latter, you should also be able to achieve with the built-in WP functions.
What do you need the profile fields for? Seems like WP_User_Query would do the job perfectly.
If role is stored as an xprofile field, you might want to look at BP_User_Query. Haven’t used that class yet, but it might do what you want.
Also, a select box might not be the best option for what you have in mind. Imagine you’ll get a result of a couple hundred users. Becomes completely unusable. Not sure what your ultimate goal is with that selectbox, but I’d look at other options.
We actually have a pretty limited number of users, who are paired as mentees and mentors. We want each mentor/mentee to be able to select their corresponding mentee/mentor from the list to make sure the spelling is the same. We also want to show linked pairs in another section, which is another headache all to itself.
The first name and last name are stored as xprofile fields because I needed the privacy and user controls that Buddypress provides. Role is also stored as an xprofile field because we’re using our own defined roles (mentor and mentee).
Looks like I’m going to have to get deep into the SQL to do this – was just hoping there was something easy I’d missed!
Boris – I was looking at BP_user_query the other day and it looked right up my alley, but do I need to wait till 1.7 to use it? (and any idea when it will be released?)
Oh, yeah, forgot that BP_User_Query’ll only land in v1.7. Can’t think of anything else apart from a custom SQL query then. Maybe a good idea to refactor it once you upgraded to BP 1.7, though.