Tagged: checkboxes, members
Hi Pause,
Here is how you can loop on that array and print the values.foreach ( $user_ids as $user_id ) { echo "For User:".bp_core_get_user_displayname( $user_id ). ' Data:' . xprofile_get_field_data("Field Name", $user_id ); }
I thought the question was related to how do you get the ids to loop around it. This is just an example. You will need to create your own displayable content loop.
Also, the previous code can be used any place. It does not need to be used in any loop. Since we are using BP_User_Query, BuddyPress needs to be active on teh site.
Regards
BrajeshHi,
i got this working with links now. Thanks for your patience with this.So to sum up this the outcome is that i can now print all users who have checked option ‘tyres’ from checkbox and print their display name with link to their profile page.
bp_core_get_userlink( $user_id );
$url = bp_core_get_user_domain( $user_id );
$username = bp_core_get_username( $user_id );$user_query = new BP_User_Query(
array(
‘xprofile_query’ => array(
array(
‘field’ => 10,
‘value’ => ‘tyres’,
‘compare’ => ‘LIKE’,
),
),
‘populate_extras’ => false,
)
);$user_ids = $user_query->user_ids;
foreach ( $user_ids as $user_id ) { ?>
“>
<?php
echo ” “.bp_core_get_user_displayname( $user_id ). ‘<br>’ . xprofile_get_field_data(“”, $user_id );}
HI Pause,
There are various functions available in BuddyPress for that. I will suggest taking a look at BP Template to get more info about them.Some of the useful functions you may use are:-
bp_core_get_user_domain( $user_id ); // Url of the user profile. bp_core_get_userlink( $user_id ); // link to user profile. bp_core_fetch_avatar( array( 'item_id' => $user_id ) ); // get user avatar.
and so on.
Regards
Brajesh
The topic ‘ [Resolved] Check if checkbox have data and print corresponding member name’ is closed to new replies.