Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to add custom profile fields to the member profiles that show on the Group > Single template but bp_member_profile_data doesn't seem to return anything.

This works fine when added to the members-loop.php:

<?php if ( bp_get_member_profile_data( 'field=Profile:' ) ) : ?>
  <?php echo '<BR><span class=memberslabel>Profile:</span> '; ?>
  <?php bp_member_profile_data( 'field=Profile:' ); ?>
<?php endif; ?>

But when I add it to groups/single/members.php it doesn't return anything.

Is there something special I need to add to make this function work in members.php?

UPDATE

The solution offered below works to get the profile data showing in on the group members loop, but it's showing the data of the last member for all members, I tried adding

<?php $user_ID = get_current_user_id(); ?>

and I also tried

<?php echo xprofile_get_field_data( 'Profile:', $bp->displayed_user->id ); ?>

but no change, how would I pass the relevant user ID into that function?

Also, it seems the profile fields are only showing for logged in users.

share|improve this question

closed as off-topic by kaiser Aug 1 at 23:30

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.

1 Answer 1

up vote 1 down vote accepted

Try the following function, which is the one i use:

 xprofile_get_field_data('Profile',$u_id);

$u_id is the user ID in case you are not in a members loop.

So in your case should be:

<?php if ( xprofile_get_field_data( 'Profile', $user_ID ) ) : ?>
  <?php echo '<BR><span class=memberslabel>Profile:</span> '; ?>
  <?php echo xprofile_get_field_data( 'Profile', $user_ID ); ?>
<?php endif; ?>

UPDATE : You will need to paste your whole code to be sure you are using this on the right place. But you could try something like:

<?php while ( bp_group_members() ) : bp_group_the_member(); ?>

            <li>
                <a href="<?php bp_group_member_domain(); ?>">

                    <?php bp_group_member_avatar_thumb(); ?>

                </a>

                <h5><?php bp_group_member_link(); ?></h5>
                <span class="activity"><?php bp_group_member_joined_since(); ?></span>

                <?php do_action( 'bp_group_members_list_item' ); ?>

                <?php if ( bp_is_active( 'friends' ) ) : ?>

                    <div class="action">

                        <?php bp_add_friend_button( bp_get_group_member_id(), bp_get_group_member_is_friend() ); ?>

                        <?php do_action( 'bp_group_members_list_item_action' ); ?>

                    </div>

                <?php endif; ?>
                <?php 
                          $user_ID = bp_get_group_member_id();
                          if ( xprofile_get_field_data( 'Profile', $user_ID ) ) : ?>
                          <?php echo '<BR><span class=memberslabel>Profile:</span> '; ?>
                               <?php echo xprofile_get_field_data( 'Profile', $user_ID ); ?>
                <?php endif; ?>
            </li>

        <?php endwhile; ?>
share|improve this answer
    
Yesss!! Thanks @chifliiiii, that works perfectly! –  maikunari Jul 10 '13 at 23:35
    
Actually not quite perfectly, see my edit above. –  maikunari Jul 11 '13 at 0:01
    
i updated my question with bp_get_group_member_id() –  chifliiiii Jul 11 '13 at 11:43
    
Thanks very much chifliiiii I haven't had a chance to get back to this yet but I'll take a closer tomorrow and let you know how it works, and paste in my code if necessary. –  maikunari Jul 12 '13 at 3:01
    
You rock so much, thanks - it now really is working perfectly! Cheers! –  maikunari Jul 12 '13 at 21:59

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