• Resolved lennydelmar

    (@lennydelmar)


    I am using on my website bbpress plugin. And as I have avatars but default so useless, additionally I use Simple User Avatar plugin to override the existed ones. How can I manage your awesome plugin to show avatars from the plugin I use? Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author wordplus

    (@wordplus)

    Hi there!

    To modify avatars you can use this filter:
    https://www.better-messages.com/docs/development/php-filters/better_messages_rest_user_item

    This is example for that plugin

    add_filter('better_messages_rest_user_item', 'custom_user_avatar', 20, 3 );
    
    function custom_user_avatar( $item, $user_id, $include_personal ){
    	if ( ! defined('SUA_USER_META_KEY') ) return $item;
    	
    	
        $attachment_id = get_user_meta( $user_id, SUA_USER_META_KEY, true );
        if ( empty($attachment_id) || !is_numeric($attachment_id) ) {
    	 	return $item;
        }
    	
        $attachment_src = wp_get_attachment_image_src( $attachment_id, 'medium' );
    	
    	if( $attachment_src ) $item['avatar'] = $attachment_src[0];
    	
        return $item;
    }
    Thread Starter lennydelmar

    (@lennydelmar)

    Thanks a lot! Work perfectly for me by pasting code into phunctions.php theme file.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Avatar override’ is closed to new replies.