AvatarManager
\Benecaster\Avatar\AvatarManager
Manages subscriber avatar storage and output. Hooks into WordPress’s avatar system (get_avatar_url, get_avatar) and BuddyPress (bp_get_user_avatar) to substitute uploaded subscriber avatars for the default Gravatar or WordPress fallback. Falls through to the original value untouched when the subscriber has no avatar, avatars are disabled site-wide, or the user is not a subscriber.
Registered via AvatarManager::register() during plugin init. Third-party code should use the class helpers rather than reading the underlying user meta directly. Short-circuits entirely when the benecaster_avatars_enabled option is '0'.
Methods
| Method | Visibility | Since | Description |
|---|---|---|---|
get_attachment_id( int $user_id ): int |
Public | — | Returns the attachment ID from _benecaster_avatar_attachment_id user meta, or 0 if the meta is absent or the referenced attachment has been deleted. Handles stale meta transparently. |
get_url( int $user_id ): ?string |
Public | — | Returns the URL for the subscriber's avatar, or null if no avatar is set or the attachment is missing. |
resolve_user_id( mixed $id_or_email ): int |
Public | — | Normalizes the first argument accepted by WordPress's get_avatar() family into a WP user ID. Accepts int, WP_User, WP_Post, WP_Comment, or email string. Returns 0 when resolution fails. |
Constants
| Name | Value | Description |
|---|---|---|
META_KEY |
'_benecaster_avatar_attachment_id' |
WordPress user meta key where the attachment ID of the subscriber's current avatar is stored. |