BuddyPress – Get a List of Defined xProfile fields

“How can I retrieve all xProfile fields?”

Related posts

1 comment

  1. You can pass the user id in Bp Profile loop to get hold of alll the fields and their values.

    <?php
    if ( bp_has_profile(array('user_id' => 1)) ) :
     while ( bp_profile_groups() ) : bp_the_profile_group(); ?>
    
    <ul id="profile-groups"> <?php
     if ( bp_profile_group_has_fields() ) : ?>
    
      <li>
        <?php bp_the_profile_group_name() ?>
    
        <ul id="profile-group-fields">
        <?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?>
    
          <?php if ( bp_field_has_data() ) : ?>
          <li>
            <?php bp_the_profile_field_name() ?>
            <?php bp_the_profile_field_value() ?>
          </li>
          <?php endif; ?>
    
        <?php endwhile; ?>
        </ul>
      <li>
    
    <?php endif; ?>
    </ul>
    
    <?php endwhile; ?>
    
    <?php else: ?>
    
    <div id="message" class="info">
       <p>This user does not have a profile.</p>
     </div>
    
    <?php endif;?>
    

    This will give you group name and all the fields name, with values

Comments are closed.