Skip to:
Content
Pages
Categories
Search
Top
Bottom

adding profile url and xprofile field data to user meta?


  • LaurieDugdale
    Participant

    @lauriedugdale

    Hi,

    Is there a way to add the url of a users avatar to user meta? I’m not very good with php at all but so far I have this in member-header.php:

                $user_id = bp_displayed_user_id();            
                
                $avatarurl = bp_displayed_user_avatar( 'html=false' );
    
                $metadata = bp_update_user_meta( $user_id, 'avatar_url', $avatarurl );
    
    

    Also being able to add xprofile fields to user meta would be very useful.

    Any help greatly appreciated!

Viewing 2 replies - 1 through 2 (of 2 total)

  • LaurieDugdale
    Participant

    @lauriedugdale

    Found the code below on these forums works perfectly.

    function my_cache_avatar_url() {
    	update_user_meta( bp_displayed_user_id(), 'modemloopers_awesome_avatar_url', bp_core_fetch_avatar( 'html=false&item_id=' . bp_displayed_user_id() ) );
    }
    add_action( 'xprofile_screen_change_avatar', 'my_cache_avatar_url' );
    

    I’ve tried to make it work for an xprofile field by doing the code below with no such luck. Any ideas?

    
    function my_cache_xprofile_website() {
    	update_user_meta( bp_displayed_user_id(), 'modemloopers_awesome_website_url', bp_profile_field_data('field=Website&item_id=' . bp_displayed_user_id() ) );
    }
    add_action( 'xprofile_updated_profile ', 'my_cache_xprofile_website' );
    

    danbp
    Participant

    @danbp

    xprofile component use his own tables:
    _bp_xprofile_data
    _bp_xprofile_fields
    _bp_xprofile_groups
    _bp_xprofile_meta
    See here for detailed structure: https://codex.buddypress.org/developer/buddypress-database-diagram/

    Somehow related to your question, this topic who explains how to use bp_update_user_meta (update_user_meta belongs to WP)

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘adding profile url and xprofile field data to user meta?’ is closed to new replies.
Skip to toolbar