BuddyDev

Search

I want to hook my code once the user profile avatar is moderated and approved

Tagged: 

  • Participant
    Level: Initiated
    Posts: 5
    Darren Burn on #41318

    I want to hook my code once the user profile avatar is moderated and approved to get the moderated profile avatar URL.
    Which I want to update in usermeta table for custom-built functionality.

    I found this hook “bpavmod_avatar_approved” by looking into the code but it is not working.

  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #41324

    Hi Darren,
    Welcome to BuddyDev forums.

    I had a look at the code and it is working fine for me.

    How are you using(It is an action). Please share your code and I will assist.

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 5
    Darren Burn on #41326

    here is the sample code.

    add_action( ‘bpavmod_avatar_approved’, function($avatar) {
    var_dump($avatar); die;
    } );

  • Participant
    Level: Initiated
    Posts: 5
    Darren Burn on #41329

    This works on the very next manual reload of page “wp-admin/admin.php?page=user-avatar-moderation&action=approve&id=13&nonce=*********” but once the “Approve” button is clicked and page reloads with successful moderation, this code does nothing.

    and returning me an instance of the “BPAVMOD_Moderation_Log” class

    • This reply was modified 3 years, 1 month ago by Darren Burn.
  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #41339

    Hi Darren,
    I am not sure what you want.

    The code is working fine on approval. Approval happens when you click on the button. The next page is a redirect.

    The code works fine as it gives you access to moderation object when you click on approve. The next page is not the approval action. The next page is where you go after successful approval.

    If your goal is to access the user id, you can use `$avatar>uploaded_by’

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 5
    Darren Burn on #41384

    how to get the approved avatar’s URL?

  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #41416

    Please use the following sample code.

    
    
    add_action( 'bpavmod_avatar_approved', function ( $avatar ) {
    	$url = bp_core_fetch_avatar( array(
    		'object'  => $avatar->item_type,
    		'item_id' => $avatar->item_id,
    		'type'    => 'full',
    		'html'    => false,
    	) );
    
    	// do something with the $url.
    } );
    

    Regards
    Brajesh

You must be logged in to reply to this topic.

This topic is: not resolved