Here it is the full function (untested):
function bpdev_get_birthday_from_dob($dob_field_name,$user_id=false){
if(!$user_id)
$user_id=bp_displayed_user_id ();
$dob_time=xprofile_get_field_data($dob_field_name, $user_id);//get the datetime as myswl datetime
$dob=new DateTime($dob_time);//create a DateTime Object from that
return $dob->format(‘F, d’);
}
@sgr33n, the code did not work. it just return empty.
I know this is an extremely old thread but as Buddypress is linking to it for tips and tricks, I figured this is still relevant.
@sbrajesh, I used your snippet for adding age into my users’ profiles and it worked to the extent that I somehow made the admin, me, the default age. It looks great, but all my hypothetical users are 33! This seems like a placement issue but I can’t figure it out.
I’m using the latest WP and BP Default with a child theme, and I placed the first part of sbrajesh’s code in my bp-custom.php and the second part in the members-header.php to start with.
Anyone’s help would be awesome.
Actually, whoever is logged in is the default age, and when logged out, everyone is age 0 in the member directory. When logged out each user’s profile page shows their proper age.
Like I said, I think I just placed either the first part of the code or this “usage” snippet in the wrong place, but I think some kind of “loggedout” verbiage is still needed. One of you wizards please help me.