BuddyDev

Search

[Resolved] Coding question: get_userdata() similar function for Buddypress?

  • Participant
    Level: Enlightened
    Posts: 30
    Michael on #52824

    Quick question:

    Does Buddypress have a function like the WP function “get_userdata()” , where I can pass only the user_id and all the Buddypress profile info is returned as an object? And I can then use $object->field_name to get the data?

    For example, something like this :

    
    $data = bp_return_all_profile_info ($user_id);
    
    echo $data->location;
    echo $data->job;
    
    etc.
    

    Thanks guys!

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #52827

    Hello Michael,

    Thank you for posting. There is no similar function available in BuddyPress which returns all field info as a single object. But you can use the BuddyPress profile loop to fetch all the user profile details. Check the following link for reference:

    https://codex.buddypress.org/developer/loops-reference/the-profile-fields-loop-bp_has_profile/

    To get a user’s specific field data, you can use the function ‘xprofile_get_field_data’. Please check.

    Regards
    Ravi

  • Participant
    Level: Enlightened
    Posts: 30
    Michael on #52828

    Thanks Ravi, appreciated.

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #52829

    Thank you for the acknowledgement. I am glad that I could help.

    Regards
    Ravi

The topic ‘ [Resolved] Coding question: get_userdata() similar function for Buddypress?’ is closed to new replies.

This topic is: resolved