Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?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

diegopau commented Apr 26, 2021

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

champsupertramp commented Apr 27, 2021

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

diegopau commented Apr 27, 2021

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