• Resolved Mineshrai

    (@mineshrai)


    Hi,
    I am using this plugin on my website & it is working fine. The only point I am not convinced with this plugin is that it is not showing a default avatar or mystery man on both pages i.e. “All Users” & “Your Profile” pages.

    Means if I don’t want to add an avatar or if any of my website user don’t want to upload avatar then in such case the plugin should display default avatar.

    Can you plz add this function in future update.

    Thnks

    • This topic was modified 7 years, 3 months ago by Mineshrai.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter Mineshrai

    (@mineshrai)

    UPDATE

    I have updated the code as follows

    	if ( $user_id == 0 ) return $avatar;
    	$custom_avatar = get_user_meta( $user_id, 'custom_avatar', true );
    	$image = crazicle_get_attachment_url( $custom_avatar, 'thumbnail' );
            $default = "https://www.example.com/assets/images/mystery-man.png";
    
    	if( empty($image) ) {
                            
                    $avatar = "<img alt='{$alt}' src='{$default}' class='avatar avatar-{$size} photo' height='{$size}' width='{$size}' />";
    
            } else {
    
    		$avatar = "<img alt='{$alt}' src='{$image}' class='avatar avatar-{$size} photo' height='{$size}' width='{$size}' />";
            }
    
    	return $avatar;
    Plugin Author Matteo Manna

    (@matteomanna)

    Thank you Mineshrai, I will update plugin with your code.

    This still hasn’t been updated and I was wondering where I can add the code provided by Mineshrai. Which file?

    Is this plugin not being supported any longer?

    Thread Starter Mineshrai

    (@mineshrai)

    Hi @nootkan,
    I have not checked whether the plugin is updated or not. But if you want this feature you have to modify the code in the index.php file available in the plugin folder.

    Note: Beware that if the plugin gets any update in future, the changes you have made will be lost…

    • This reply was modified 6 years, 8 months ago by Mineshrai.

    Hi Mineshrai, thanks for your reply. When I installed the plugin the default avatar wasn’t there or an option to create one so I assumed the plugin wasn’t updated.

    I tried adding your code to the bottom of the index.php file but that didn’t work either.

    I also tried changing this

    if ( $user_id == 0 ) return $avatar;
    
        $mm_sua_attachment_id = (int)get_user_meta( (int)$user_id, 'mm_sua_attachment_id', true );
        $image = mm_sua_get_attachment_url((int)$mm_sua_attachment_id, 'thumbnail');
        if( empty($image) ) $avatar = '';
    
        $avatar = preg_replace('/src=("|\').*?("|\')/i', 'src="'.$image.'"', $avatar);
        $avatar = preg_replace('/srcset=("|\').*?("|\')/i', 'srcset="'.$image.'"', $avatar);
    
        return $avatar;

    with your suggested modification but that didn’t work either. I have decided to use the WP User Avatar 2.0.9 plugin instead as it gives me what I want.

    Thanks for your support.

    • This reply was modified 6 years, 8 months ago by nootkan.
    • This reply was modified 6 years, 8 months ago by nootkan.
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Default avatar is not appearing’ is closed to new replies.