[buddypress-trac] [BuddyPress] #2171: Calling bp_member_profile_data() while in bp_has_members() loop results in null string on all subsequent bp_member_XXX() calls
buddypress-trac at lists.automattic.com
buddypress-trac at lists.automattic.com
Thu Mar 11 04:00:27 UTC 2010
#2171: Calling bp_member_profile_data() while in bp_has_members() loop results in
null string on all subsequent bp_member_XXX() calls
--------------------------------------------------------------------+-------
Reporter: foxly | Owner:
Type: defect | Status: new
Priority: major | Milestone: 1.2.3
Keywords: bp_member_profile_data() , bp_get_member_profile_data() |
--------------------------------------------------------------------+-------
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.
--
Ticket URL: <http://trac.buddypress.org/ticket/2171>
BuddyPress <http://buddypress.org/>
BuddyPress
More information about the buddypress-trac
mailing list