Tagged: member type pro
Hi there, I need to trail an unrelated URL with all of the user IDs of a specific member type. It needs to look like this – http://www.randomURL.com/URLAction&1,2,3,4,5 (where the numbers at the end are user IDs separated by a comma).
Can you please advise the best way to do this?
Thanks so much!!
Hi,
Thank you for the question. I do not see a direct way to do it currently. BuddyPress does not have an API to fetch all user ids of a member type without fetching their all data(wp user info data). That is not efficient.If you still want it, I will post a sample with BP_User_Query.
Thank you
BrajeshHi,
yes, the role based fetching is very easy.Here is a code to get all user ids for subscriber role.
$users_ids = get_users( array( 'role' => 'subscriber', 'fields' => 'ID' ) );
Please feel free to change the role appropriately.
Regards
BrajeshHi
After this line$users_ids = get_users( array( 'role' => 'subscriber', 'fields' => 'ID' ) );
You can use
$list = join( ',', $users_ids );
The list will have the comma separated list.
Regards
Brajesh
You must be logged in to reply to this topic.