Skip to content

Member avatar upload

When enabled, members can upload their own profile photo from the account menu header. The uploaded image replaces their Gravatar everywhere WordPress shows an avatar, including comments and author boxes.

Open the General tab and turn on Member avatar upload. A change-photo control then appears in the account menu header on the front end.

  • The upload form loads through a WooCommerce AJAX request and is available only to logged-in members.
  • Uploads are validated against an allowlist of image types: JPEG, PNG, GIF and WebP.
  • Files larger than 2 MB are rejected with a notice.
  • The image is stored as a media-library attachment and its id is saved to the wb-wcmp-avatar user meta key.
  • After a successful upload the member is redirected back to the dashboard (post-redirect-get), so a page refresh does not resubmit.

The form includes a reset control. Resetting deletes the uploaded attachment and the wb-wcmp-avatar user meta, so the member falls back to their Gravatar.

The custom avatar hooks WordPress’s shared get_avatar filter at priority 100 and uses a re-entrancy guard. It does not remove other plugins’ avatar callbacks, so it coexists with BuddyPress, Simple Local Avatars and similar plugins.

To hand avatar rendering to another source, return true from the wcmp_get_avatar_filter filter. See Filters and actions.