WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Show "birthdate" in registration page and "Age" in profile page

[Resolved] Show "birthdate" in registration page and "Age" in profile page

  • Hi,

    I selected “Show age (hide birthdate)”, and I’d like to know how to show “Date of Birth” on the registration page, and “Age” as label on profile page. Because if I select “Show age”, it’s more logical to show “Age” as label on profile page rather than “Date of birth” if this is the age that is displaying. What do you think?

    Thanks for this awesome plugin.

    http://wordpress.org/extend/plugins/buddypress-xprofile-custom-fields-type/

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

    @atallos

    I think you find the answer in the other topic, no ?

    Hi,

    Not exactly. In fact:
    – In the registration page, I have: “Date of Birth: XX/XX/XXX”.
    – In profile page, I have: “Date of Birth: 27” for someone who has 27 years old.
    -> My question: how to show “Age: 27” rather than “Date of Birth: 27” on profile page, and keeping in the same time “Date of Birth: XX/XX/XXX” mention on the registration page.

    What I need to have is a different title field according I’m on registration page or on profile page, cause it’s not the same thing (one is the date of birth, one is the age).

    Sorry for my approximate English:) I hope it’s clearer now 🙂

    Plugin Author donmik
    Member

    @atallos

    You can add a filter to the label too.

    Add this to your functions.php:

    function my_bp_get_the_profile_field_name($name) {
        if ($name == 'Date of Birth' && strpos($_SERVER['REQUEST_URI'], '/register') === false) {
            return 'Age';
        }
        return $name;
    }
    add_filter ( 'bp_get_the_profile_field_name', 'my_bp_get_the_profile_field_name', 15, 1);

    $name will have “Date of Birth” the name of your field, you need to check it and check if you are not in the registration page. If not, you return ‘Age’.

    It works like a charm ! Thousand thanks atallos for your help and this very great plugin!

    adam1234567
    Member

    @adam1234567

    hi – this function works great when displaying the profile, but when a user edits their profile (using the buddypress menu nav) the Date of Birth field says “Age” when it should say Date of Birth. how can I fix this? thanks!

    Plugin Author donmik
    Member

    @atallos

    Hi,

    You’re totally right, use this code instead of previous:

    function my_bp_get_the_profile_field_name($name) {
        if ($name == 'Date of Birth' && !bp_is_register_page()
                && !bp_is_profile_edit()) {
            return 'Age';
        }
        return $name;
    }
    add_filter ( 'bp_get_the_profile_field_name', 'my_bp_get_the_profile_field_name', 15, 1);
    adam1234567
    Member

    @adam1234567

    that works perfectly. thanks so much!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Resolved] Show "birthdate" in registration page and "Age" in profile page’ is closed to new replies.