Skip to:
Content
Pages
Categories
Search
Top
Bottom

xprofile_avatar_uploaded and bp_core_fetch_avatar

  • @raaaa86

    Participant

    Hi,

    I have one problem with fetching avatars using bp_core_fetch_avatar() function and xprofile_avatar_uploaded action. I keep my avatars as user meta. What I want to do is to update that meta every time new avatar is uploaded from back end. I wrote this functions:

    function update_avatar_admin(){
    	update_user_meta(bp_displayed_user_id(),'profile_photo',bp_core_fetch_avatar( array( 'item_id' => bp_displayed_user_id(), 'html' => false ) ));
    }
    add_action('xprofile_avatar_uploaded', 'update_avatar_admin', 99);

    The thing is it always gets previous avatar and not the one uploaded.

Viewing 3 replies - 1 through 3 (of 3 total)
  • @shanebp

    Moderator

    That’s a tricky one. And I don’t have a solution.

    It’s probably a timing issue. The hook fires before the dir is updated.
    Or maybe bp_core_fetch_avatar is cached.

    Which version of BP are you using?
    The issue may be related to the new approach to avatar uploads using the BP_Attachments class.

    @raaaa86

    Participant

    I’m using latest: 2.3.2.1 version. I can’t figure out at what point in time is xprofile_avatar_uploaded triggered it should be after avatar is uploaded, so i should have latest path of avatar. I’m busting my head for previous 3 days to figure this out.

    @landwire

    Participant

    Hi there,
    just listening in, as I also need to use the newly uploaded/changed avatar image to update it somewhere else in the DB.
    Any news on this?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘xprofile_avatar_uploaded and bp_core_fetch_avatar’ is closed to new replies.
Skip to toolbar