Support » Plugins and Hacks » Buddypress Xprofile Custom Fields Type » [Resolved] Age not formatted right

[Resolved] Age not formatted right

Viewing 15 replies - 1 through 15 (of 16 total)
  • Plugin Author Miguel López


    Mmmm, I’m testing in:
    Wordpress 3.5
    Buddypress 1.6.2
    BP Xprofile Custom Fields Type 1.4.3

    The field set to show age works properly.

    Can you check the versions?

    I’m using W 3.5, BP XP 1.4.3 and BP 1.6.2 also, and I have already removed all of my plugins to see if something else was affecting it. Also, when I uncheck the show as age box it still shows the same way

    Plugin Author Miguel López


    We need to do some debug. Can you add this line of code in bp-xprofile-custom-fields-type.php line 381,382 you can see:

    // Get children.
    $childs = $field->get_children();

    Below this line we must add this:


    The code will look like this:

    // Get children.
            $childs = $field->get_children();

    Then reload the page where the age is supposed to be, copy and paste the code returned. It will look like this:

    0 =>
    public ‘id’ => string ’63’ (length=2)
    public ‘group_id’ => string ‘1’ (length=1)
    public ‘parent_id’ => string ‘3’ (length=1)
    public ‘type’ => string ‘birthdate_option’ (length=16)
    public ‘name’ => string ‘show_age’ (length=8)
    public ‘description’ => string ” (length=0)
    public ‘is_required’ => string ‘0’ (length=1)
    public ‘is_default_option’ => string ‘1’ (length=1)
    public ‘field_order’ => string ‘0’ (length=1)
    public ‘option_order’ => string ‘1’ (length=1)
    public ‘order_by’ => string ” (length=0)
    public ‘can_delete’ => string ‘1’ (length=1)


    array(1) { [0]=> object(stdClass)#136 (12) { [“id”]=> string(3) “447” [“group_id”]=> string(1) “1” [“parent_id”]=> string(2) “85” [“type”]=> string(16) “birthdate_option” [“name”]=> string(8) “show_age” [“description”]=> string(0) “” [“is_required”]=> string(1) “0” [“is_default_option”]=> string(1) “1” [“field_order”]=> string(1) “0” [“option_order”]=> string(1) “1” [“order_by”]=> string(0) “” [“can_delete”]=> string(1) “1” } }

    I must apologize… after I entered the code and looked around the site for the output, I noticed that the field that is SUPPOSED to show the age shows correctly!

    I have the age in the members-header and a few other places around the site (sidebar, etc.) and it is showing the 1993-12-18 00:00:00 format in those areas.

    I’ve placed: <?php if ( $data = bp_get_profile_field_data( ‘field=Age’ ) ) : ?><?php echo $data ?> To call the age.

    Is is possible to get the correct display for age in the header?

    I really appreciate you taking the time to reply back to me, and I’m sorry for the inconvenience.

    Plugin Author Miguel López


    No problem, thanks for reporting issues.

    We have just released version 1.4.4. I think it will solve your issue.

    WOW! It did! Thank you so much!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    Plugin Author Miguel López


    You welcome!

    Sorry to bother you again… but is there a way to get the age to stay on the same line? It moves to the line below in the Buddypress Avatar Bubble plugin…

    It looks like this:


    All the other lines show like this:

    Gender: Female
    Country: USA

    Thank you again!

    Never mind 🙂 Figured out a shortcut, just removed the <p></p> from the file and it works great now.

    Plugin Author Miguel López


    Ok. I was going to say you to remove this…xD.

    Hi Donmik,

    As my question is somewhat relevant to this thread I’ll post it here.

    I would like to remove the <p>…</p> that gets added to the birthdate field (and preferably all fields). I know there is this code below:

    add_filter( 'bxcft_show_field_value', 'my_show_field', 15, 4);
    function my_show_field($value_to_return, $type, $id, $value) {
        if ($type == 'birthdate') {
            $value = str_replace("<p>", "", $value);
            $value = str_replace("</p>", "", $value);
            $field = new BP_XProfile_Field($id);
            // Get children.
            $childs = $field->get_children();
            $show_age = false;
            if (isset($childs) && $childs && count($childs) > 0) {
                // Get the name of custom post type.
                if ($childs[0]->name == 'show_age')
                    $show_age = true;
            if ($show_age) {
                return '<p>'.floor((time() - strtotime($value))/31556926).'</p>';
            return '<p>'.date_i18n( 'F j' , strtotime($value) ).'</p>';
        return $value_to_return;

    But I’m not sure how to edit that just to remove the <p></p> and keep the rest the same.



    Plugin Author Miguel López



    Sorry for the delay. If you delete the “<p>” tag in this code, I think it will work. The rest of fields should stay the same.

    guess that was somewhat obvious. Thanks donmik.

    hey there,

    i use wp 3.6 and BP 1.8.1. i have the problem that the birthdate field does not show up. i can see the field description, but not the field to choose day/month and year. that prevents the whole registration process from working. do you have a hint for me?

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘[Resolved] Age not formatted right’ is closed to new replies.
Skip to toolbar