wp-user-manager icon indicating copy to clipboard operation
wp-user-manager copied to clipboard

Custom avatar not shown if set default avatar

Open tambaqui opened this issue 7 months ago • 0 comments

Current Outcome

If we enable the option to allow users to upload personalized avatars for their profiles, and they upload their own avatar, this is displayed as long as we do not establish a default avatar in WP User Manager Settings, but if we establish a default one it has priority over the one uploaded by the user himself.

Desired Outcome

The user's avatar should take priority over the default avatar.

Steps to Reproduce

  1. Activate the Custom Avatars option in WP User Manager Settings > Profiles.
  2. With a logged in user upload an image in the "Profile picture" account edition and save changes. The user's avatar is displayed correctly.
  3. Upload a default avatar in WP User Manager Settings > Profiles and save.

Suggestions

In the WPUM_Avatars class there are two filters for get_avatar_url with the same priority: First declare this: add_filter('get_avatar_url', array($this, 'set_avatar_url'), 10, 3); And then this: add_filter('get_avatar_url', array($this, 'set_default_avatar'), 10, 3);

This being so, the set_default_avatar will be executed later so it will overwrite the user's avatar.

You could change the order in the code, or change the priorities so that set_avatar_url is executed after set_default_avatar. Example:

add_filter('get_avatar_url', array($this, 'set_avatar_url'), 11, 3);
add_filter('get_avatar_url', array($this, 'set_default_avatar'), 10, 3);

tambaqui avatar Jul 24 '24 15:07 tambaqui