Skip to:
Content
Pages
Categories
Search
Top
Bottom

Display age on profile page


  • kirkslater
    Participant

    @kirkslater

    Hi

    Looking to get the “Date of Birth” field from the members profile and place it in two place, at the top of the profile page under the user name and on the members directory. I also need to display the age and not the date. Any ideas about how it do this?

    The only thing I could track down was http://code.hyperspatial.com/507/buddypress-age/ but I couldn’t get it to work.

    Any ideas?

    Cheers

Viewing 4 replies - 26 through 29 (of 29 total)
  • 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’);
    }


    funmi omoba
    Participant

    @funmi-omoba

    @sgr33n, the code did not work. it just return empty.


    aldereteka
    Participant

    @aldereteka

    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.


    aldereteka
    Participant

    @aldereteka

    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.

Viewing 4 replies - 26 through 29 (of 29 total)
  • The topic ‘Display age on profile page’ is closed to new replies.
Skip to toolbar