How to display the main site's avatar in another subsite

I'm using your Avatars plugin and I'm trying to display main site's avatar in a subsite.
Is there any workaround that could be used for this? Please advise!

  • Ivan

    Hi examden !

    I tested it and it seems it's a standard behavior for the Avatar plugin. I created a new user, logined with his credentials, opened Profile page on my main site, set avatar, opened Profile page on a subsite and I see the same avatar. Did I miss something?

    If you provide me with additional login credentials, I can look into it more.

    https://premium.wpmudev.org/contact/#i-have-a-different-question
    Please visit our private Contact page and complete the form with the following information:

    Subject: "Attn: Ivan Svyrskyi"

    In the Message box, please provide the following:

    - link back to this thread for reference
    - any other relevant urls
    - what user has this issue?
    - on what subsite?
    - WP credentials of this user

    - Admin login:
    Admin username
    Admin password
    Login url

    - FTP/SFTP credentials
    host
    username
    password
    (and port if required)

    Note: Don't send any credentials via this forum because it's public forum.

    Best regards,
    Ivan.

  • Ivan

    Hi examden !

    I got it. You could try adding the following snippet in a mu-plugin

    <?php
    function wpmu_avatars_change_subsite_default_avatar( $default, $id, $size ) {
    	if ( !is_main_site() ) {
    		global $ms_avatar;
    		$main_site = get_network()->site_id;
    
    		remove_filter( 'get_blog_default_avatar', 'wpmu_avatars_change_subsite_default_avatar' );
    		switch_to_blog( $main_site );
    		$default = $ms_avatar->get_blog_avatar_url( $main_site, $size, $default );
    		restore_current_blog();
    		add_filter( 'get_blog_default_avatar', 'wpmu_avatars_change_subsite_default_avatar', 10, 3 );
    	}
    	return $default;
    }
    add_filter( 'get_blog_default_avatar', 'wpmu_avatars_change_subsite_default_avatar', 10, 3 );

    Also, you should open {wordpress_folder}/wp-content/plugins/avatars/avatars.php file via FTP and add the following line before if ( !empty($id) ) { ( approximately 1469th line )
    $default = apply_filters( 'get_blog_default_avatar', $default, $id, $size );

    Also, I'll add this change to the next version of the plugin.

    Best regards,
    Ivan.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.