Forums

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

  1. evo252
    Member
    Posted 2 months 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. atallos
    Member
    Plugin Author

    Posted 2 months ago #

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

  3. evo252
    Member
    Posted 2 months 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. atallos
    Member
    Plugin Author

    Posted 2 months 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 2 months ago #

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

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.