Skip to:
Content

BuddyPress.org

Opened 15 years ago

Closed 15 years ago

#2171 closed defect (bug) (fixed)

Calling bp_member_profile_data() while in bp_has_members() loop results in null string on all subsequent bp_member_XXX() calls

Reported by: foxly's profile foxly Owned by:
Milestone: 1.2.3 Priority: major
Severity: Version:
Component: Keywords: bp_member_profile_data(), bp_get_member_profile_data()
Cc:

Description

When generating friend lists and user lists in buddypress, clients often want developers to populate them with users’ extended profile data. This is done using the function bp_member_profile_data(‘fieldname’) where ‘fieldname’ is the name of the extended profile field.

However, calls to the functions bp_member_permalink(), bp_member_name(), bp_member_last_active(), bp_member_latest_update(), and bp_member_add_friend_button() are required to supply important member information and generate the friendship add / cancel button.

If bp_member_profile_data() is called at ANY point in the loop before the above five functions, ALL calls following it from the above five functions will return a null string until the next iteration of the loop.

This creates a major problem for template designers, because it makes it difficult to generate friend listing titles like “Member Name – Single Female in Anywhere Canada” and very difficult to move the “Add Friend” button within a friends list element (because the BP developers decided to implement the button in a function instead of in the template)

To replicate the problem:

On a default buddypress installation with the default theme selected, add:

<?php bp_member_profile_data('field=XXX') ?>
(where ‘XXX’ is the name of a valid field in the BP extended profile)

At line 26 in members/members-loop.php

Then visit a user’s “friends” page.

Each “friend” listing will display the contents of the extended profile field, but “status” will always display as “not recently active”, the status field will be missing, and the “action” button will display “add friend” regardless of whether or not the user is a friend.

This demonstrates a defect in the bp_member_profile_data () function, because calling a “template tag” or “read-only” function should not zero the output of another, unrelated function.

IMPORTANT: There is no documentation for *any* of the functions listed above in the buddypress source code, and the documentation on the buddypress website is incomplete and / or out of date. (Forum posts are not an acceptable form of documentation as they often contain outdated or incorrect information.)

Please consider releasing properly documented source code.

Change History (2)

#1 @apeatling
15 years ago

Please consider helping with documentation.

#2 @apeatling
15 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [2834]) Fixes #2171

Note: See TracTickets for help on using tickets.