• Resolved atburi

    (@aburi)


    When I use bp_get_member_profile_data( 'field=Birthdate' ); to retrieve the birthday, it outputs it as 1983-07-24 00:00:00.

    When I use xprofile_get_field_data( 'Birthdate', $user_id ); it outputs it correctly as the age number.

    Any idea why these two functions pull a different result, and which functions is the better one to use in general for pulling profile fields data?

    I did a search online for xprofile_get_field_data() to try to read up on it but BP doesn’t seem to focus on it in its codex.

    Thanks,
    Alex

    https://www.ads-software.com/extend/plugins/buddypress-xprofile-custom-fields-type/

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

    (@atallos)

    Hi,

    Sorry for the delay. The two functions will return the “same thing” but apply different filters on it.

    The first “bp_get_member_profile_data” applies “bp_get_member_profile_data” filter and sends only one argument that is the value: “1983-07-24 00:00:00”. So in my plugin I need to know what field is and with this data I can’t guess what field it is and I can’t decide to return the age or the birthdate. This is why I don’t use this filter and you can’t use this function to return values from fields created with my plugin.

    In the second function “xprofile_get_field_data”, it applies a filter “xprofile_get_field_data” who sends the value and the id of the field. With this data, I can look what field is and know if you want to display age or only birthdate.

    I hope I explained correctly.

    Thread Starter atburi

    (@aburi)

    Thanks donmik, that makes sense… thanks for taking the time to respond.

    I’ll stick to xprofile_get_field_data()

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Displaying the Birthday via two different functions’ is closed to new replies.