WordPress.org

Ready to get started?Download WordPress

Forums

Buddypress Xprofile Custom Fields Type
[resolved] Age not formatted correctly on member directory (5 posts)

  1. sara.vandeste
    Member
    Posted 1 year ago #

    Hi,
    I have the birthday field set to "show age". Age is correctly displayed on users profile but not on members directory (showing birthday date insted).

    I'm using <?php bp_member_profile_data( 'field=Age' );?> to call the age field.

    How can I display it correctly?

    Thanks for your help!

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

  2. donmik
    Member
    Plugin Author

    Posted 1 year ago #

    Hi,

    You need to create a function to calculate your age you can use my plugin for example. Put this code in the functions.php in your theme:

    function echo_age($birthdate) {
        echo floor((time() - strtotime($birthdate))/31556926);
    }

    Now instead of using this
    <?php bp_member_profile_data( 'field=Age' );?>

    Use this:
    `<?php echo_age(bp_get_member_profile_data('field=Age')); ?>

    And it will work I think.

  3. sara.vandeste
    Member
    Posted 1 year ago #

    Hi!
    It's not working perfectly!
    Thank you so much for your help! ;)

  4. evo252
    Member
    Posted 1 year ago #

    Thousand thanks for this tip Atallos, and for your very very useful plugin!

  5. donmik
    Member
    Plugin Author

    Posted 1 year ago #

    You welcome! ;)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.