Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author donmik

    (@atallos)

    Hi,

    You can change in wordpress settings – General – Date Format.

    Or you can create a filter in your functions.php like this:

    function my_show_field_value($value_to_return, $type, $id, $value) {
        $field = new BP_XProfile_Field($id);
        if ($type == 'birthdate') {
            // Get children.
            $childs = $field->get_children();
            $show_age = false;
            if (isset($childs) && $childs && count($childs) > 0 && is_object($childs[0])) {
                if ($childs[0]->name == 'show_age')
                    $show_age = true;
            }
            if ($value != '') {
                if ($show_age) {
                    $value_to_return = '<p>'.floor((time() - strtotime($value))/31556926).'</p>';
                } else {
                    $value_to_return = '<p>'.date_i18n('Here goes your date format' ,strtotime($value) ).'</p>';
                }
            }
        }
    
        return $value_to_return;
    }
    add_filter('bxcft_show_field_value', 'my_show_field_value', 10, 4);

    Replace the sentence “Here goes your date format” with your date format.

    Thread Starter ultimateuser

    (@ultimateuser)

    Sorry, I didn’t explain myself properly.

    I mean that on my login page the default values are ‘9 March 1966’

    It makes more sense if the date is not already filled in when a user is signing up.

    Plugin Author donmik

    (@atallos)

    Hi,

    I believe it’s because you have default value in the database. Search this table: bp_xprofile_data and here you need to find the date 6 march 1966 in this format:
    1966-03-06 00:00:00 probably with user_id=0. If you delete this entry I think it will work.

    Also, if you delete the field and you recreate it must work. I don’t know why this is working this way. Maybe when I have more time I can investigate why.

    Thread Starter ultimateuser

    (@ultimateuser)

    Thanks that worked

    I have a problem that for every new registration, the default values are left from the last registration.

    Any help?

    Thread Starter ultimateuser

    (@ultimateuser)

    Yes I’m having the same problem now too…

    Plugin Author donmik

    (@atallos)

    I don’t know why. In my test site, this is not happening. Is this happening always? With every registration or only with some of them?

    in my case with every registration.
    I see that it’s the same with regular checkboxes fields, so my guess is, that’s not your plugin fault…
    maybe some cache issues?

    Plugin Author donmik

    (@atallos)

    Are the default values inserted in database with user_id = 0?

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Default values DOB field’ is closed to new replies.