April 21, 2016 at 5:35 pm #51788
I’ve added an extended profile using xprofile fields, and I’m displaying some of the fields on the members list page. But, if someone has left a field blank, their profile is displaying the data for the last member who did complete that field. (So, if I didn’t put my city but the person displayed before me did, that person’s city is showing in my profile.) You can see what I mean here: http://yarngroup.wpengine.com/members/
I copied members-loop.php to a buddypress folder in my main theme folder, and here’s the code I added to display the name, city and state:1234567891011121314151617181920212223242526272829303132333435363738394041424344454647/*** Fires inside the display of a directory member item.** @since 1.1.0*/do_action( 'bp_directory_members_item' ); ?>< ?php/**** If you want to show specific profile fields here you can,* but it'll add an extra query for each member in the loop* (only one regardless of the number of fields you show):**bp_member_profile_data( 'field=the field name' );*/bp_member_profile_data( 'field=Your Name' );echo '<br />';bp_member_profile_data( 'field=City' ); echo ', '; bp_member_profile_data( 'field=State' );echo '<br />';?><a href="<?php bp_member_permalink(); ? rel="nofollow">">View Member Profile</a><div class="action">< ?php/*** Fires inside the members action HTML markup to display actions.** @since 1.1.0*/do_action( 'bp_directory_members_actions' ); ?></div>< ?php endwhile; ?><div class="clear"></div>
Is there some additional code I need to add to make sure that field data from other members isn’t displaying in the wrong profile?
Thanks!April 21, 2016 at 9:29 pm #51793
The script seems to be fine so I am not sure what it is happening.
You can try specifying the member ID in the function.
You can get the member ID using:12global $members_template;$user_id = $members_template->member->ID;
Then get the field data using:1bp_member_profile_data( array( 'field' => 'City', 'user_id' => $user_id ) );
I hope that helps.April 30, 2016 at 5:13 pm #51950
This topic marked “Resolved” due to inactivity. If you wish to reply to this topic please change its status to “Not resolved” before replying.
You must be logged in to reply to this topic.