I'm working on a buddypress site in which members are allowed to post an ad that appears in the member directory, provided they also set an expiration date for it. Both fields are just Extended Profile Fields; the ad is a text area and the expiration date is, of course, a date picker.
In my theme, within the members-loop.php loop, I have the following code:
// This one works
<?php $ad = bp_get_member_profile_data('field=Member Directory Ad'); ?>
// This one doesn't
<?php $ad_expiry = bp_get_member_profile_data('field=Member Directory Ad Expiration'); ?>
There is no other special code to make this happen. I see no reason why the $ad_expiry is blank for a member who definitely has it set, especially when $ad has the correct value.
Digging into the buddypress code, my extended profile datebox data is not being returned by bp_get_member_profile_data(). Inside xprofile_format_profile_field() the value is being "formatted" by bp_format_time() and the output is empty. So I guess it's a buddypress bug.
Try this workaround -
//you need to specify the $user_id
$ad_expiry = xprofile_get_field_data('Member Directory Ad Expiration', $user_id );
// reformat, if you like
$ad_expiry = strtotime($ad_expiry);
echo date('m/d/Y', $ad_expiry);
.
And thanks for the bug report on trac.