Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save champsupertramp/f2c37356396f6c7d2366 to your computer and use it in GitHub Desktop.
Save champsupertramp/f2c37356396f6c7d2366 to your computer and use it in GitHub Desktop.
<?php
/***
*** @Dettach um default avatar
***/
add_filter('avatar_defaults', 'um_avatar_defaults', 99999 );
function um_avatar_defaults($avatar_defaults) {
remove_filter('get_avatar', 'um_get_avatar', 99999, 5);
return $avatar_defaults;
}
/***
*** @Override avatars with a high priority
***/
add_filter('get_avatar', 'my_own_avatar', 999999, 5);
function my_own_avatar($avatar = '', $id_or_email='', $size = '96', $avatar_class = '', $default = '', $alt = '') {
// Insert new source of avatar
}
?>
@diegopau
Copy link

Hi @champsupertramp would it be possible to get an update of this gist so it works with the latest version of Ultimate Member?

I am trying something with:

add_filter("um_get_option_filter__default_avatar","um_get_option_filter__default_avatar", 10, 1);
   function um_get_option_filter__default_avatar( $option ){

  return $option;
}

But I don't know how to assign the new URL to the array $option, I am not a developer.

@champsupertramp
Copy link
Author

Hi @diegopau

You can add the direct Image URL.

add_filter("um_get_option_filter__default_avatar","um_get_option_filter__default_avatar", 10, 1);
   function um_get_option_filter__default_avatar( $option ){
     $option = "https://via.placeholder.com/250";
  return $option;
}

Regards,

@diegopau
Copy link

Thanks, however it is not working.

I tried adding this to functions.php but I still see the old default avatar

add_filter("um_get_option_filter__default_avatar","um_get_option_filter__default_avatar", 999999, 1);
     function um_get_option_filter__default_avatar( $option ){
        $option = "https://s3.us-east-2.amazonaws.com/oceanbuilders.com/web_assets/default-avatar.svg";
        return $option;
     }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment