Buddypress Add unserialized Profile Fields in Members Loop

I’m trying to show profile fields with checkboxes and drop-downs in the members directory loop.

Example: Next to each member in the directory I want to show the Gender they selected

Read More

This code works for text fields:

echo xprofile_get_field_data('Full Name', bp_get_member_user_id());

BUT how do I echo profile fields for drop-downs or checkboxes (unserialized data)?

Related posts

Leave a Reply

3 comments

  1. I believe xprofile_get_field_data is unserializing the data for you, but it is still in an array.

    xprofile_get_field_data can return an array or a comma-separated string.

    xprofile_get_field_data( $field, $user_id = 0, $multi_format = 'array' )
    

    @param string $multi_format

    • How should array data be returned?
    • ‘comma’ if you want a comma-separated string
    • ‘array’ if you want an array
  2. Got it working. Wrap the profile fields in a profile loop within the members loop and the data will output properly, just as it would inside of the profile loop.

    <?php while ( bp_members() ) : bp_the_member(); ?>
    <?php bp_member_profile_data( 'field=Gender' );?>
    <?php endwhile; ?>