WordPress.org

Ready to get started?Download WordPress

Forums

Buddypress Xprofile Custom Fields Type
[resolved] Show "birthdate" in registration page and "Age" in profile page (8 posts)

  1. evo252
    Member
    Posted 1 year ago #

    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/

  2. donmik
    Member
    Plugin Author

    Posted 1 year ago #

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

  3. evo252
    Member
    Posted 1 year ago #

    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 :)

  4. donmik
    Member
    Plugin Author

    Posted 1 year ago #

    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'.

  5. evo252
    Member
    Posted 1 year ago #

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

  6. adam1234567
    Member
    Posted 8 months ago #

    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!

  7. donmik
    Member
    Plugin Author

    Posted 8 months ago #

    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);
  8. adam1234567
    Member
    Posted 8 months ago #

    that works perfectly. thanks so much!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.