1

"How can I retrieve all xProfile fields?"

closed as off-topic by Nicolai, gmazzap, birgire, fuxia Jul 31 '14 at 19:16

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

  • A better question would be: "How can I retrieve all xProfile fields?" – Rachel Baker Nov 8 '13 at 2:52
  • 1
    "How can I retrieve all xProfile fields?" :) – Jon Lachonis Nov 8 '13 at 5:05
  • if it works for you, you can mark it as an answer, so that it do not appears in Unanswered list – sven Nov 8 '13 at 13:08
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

  • One thing though, how do I get them into an array? – Jon Lachonis Nov 8 '13 at 15:59
  • you can use bp_get_the_profile_field_input_name, bp_get_the_profile_field_value to store them in a variable instead of directly echoing them. – sven Nov 9 '13 at 7:55

Not the answer you're looking for? Browse other questions tagged or ask your own question.