Skip to:
Content
Pages
Categories
Search
Top
Bottom

Using xProfile custom field values

  • @holdench

    Participant

    I want to use them separately. So say I have an address field, I want to call current user’s address only, so I can use it in, for example, the members directory.

    Tried this code :

    global $bp; $ud = get_userdata( $bp->displayed_user->id ); echo $ud->Address;

    No go though. Any thoughts fellow developers? I dont want to have to write a custom plugin for functionality that should already exist.

    Noiticed this function in the xprofile folder:

    bp_get_the_profile_field_value

    It must help me somehow, but how do I use it if it has no variables?

Viewing 8 replies - 1 through 8 (of 8 total)
  • @holdench

    Participant

    There’s also this:

    get_value_byfieldname in the bp-xprofile-classes.php at line 1110.

    I should be able to use this too, right?

    @johnjamesjacoby

    Keymaster

    Which version of BuddyPress are you using?

    In the trunk, you’d be best to use…

    function xprofile_get_field_data( $field, $user_id )

    …to get what you’re after.

    Used like…

    $retval = xprofile_get_field_data( 'Address', $bp->loggedin_user->id );

    That would return the value of the field “Address” for the currently logged in user.

    @holdench

    Participant

    Thanks JJJ, but I want to flip through the addresses of all members in the directory. So each member (hotels in my case) would have a profile with a link to google maps, phone number and website listing on the directory.

    @johnjamesjacoby

    Keymaster

    Shouldn’t change anything? I would maybe build a custom function to get around globalizing anything in the theme though…

    Something like…

    function custom_member_list_xprofile_data($field) {
    global $site_members_template;

    return xprofile_get_field_data($field, $site_members_template->member->id);
    }

    Then in your members-loop.php use it like…

    <?php echo custom_member_list_xprofile_data('Address') ?>

    In members-loop.php, the function “bp_the_site_member()” loads up the next user in the loop, so you have the data there to use; you just need to gather it correctly and prepare it for display.

    @holdench

    Participant

    This is why they pay you the big bucks right? haha, thanks jjj. Looks like i had the wrong function in my function in the first place.

    Thanks again

    @johnjamesjacoby

    Keymaster

    If “James” wasn’t my middle name, it would probably be “Support.”

    John Support Jacoby just doesn’t have the same ring to it though… ;)

    You’re very welcome.

    @holdench

    Participant

    Hey, one more question for you. Any idea how to make one of the custom fields and file upload button for the xprofile plugin? I do have the need. No worries if you don’t know.

    @johnjamesjacoby

    Keymaster

    I can see different people wanting different things out of XProfile, but at the moment there isn’t a file upload option. Basically, you would need to write an entire API for where that upload physically ends up and how you retrieve it, which is more plugin territory than it is built into XProfile.

    My suggestion would be to look at how other plugins handle the upload process, and see if you can borrow some code from them?

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Using xProfile custom field values’ is closed to new replies.
Skip to toolbar