Title: custom avatar
Last modified: October 20, 2024

---

# custom avatar

 *  Resolved [vl4d](https://wordpress.org/support/users/vl4d/)
 * (@vl4d)
 * [1 year, 7 months ago](https://wordpress.org/support/topic/custom-avatar-7/)
 * Hello i start using the plugin but my theme have custom avatar in db is like 
   this
   meta_key: Custom_User_avatar meta_value: content/themes/custom/avatar/chibi/
   chibi_1.pnghow to make the comments system to read this type of avatar and not
   the deafult wp?
    -  This topic was modified 1 year, 7 months ago by [vl4d](https://wordpress.org/support/users/vl4d/).

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Support [gVectors Support](https://wordpress.org/support/users/gvectorssupport/)
 * (@gvectorssupport)
 * [1 year, 7 months ago](https://wordpress.org/support/topic/custom-avatar-7/#post-18085313)
 * Hi,
 * You should use the native WordPress get_avatar hook to implement the custom avatars.
 * More info here: [https://developer.wordpress.org/reference/hooks/get_avatar/](https://developer.wordpress.org/reference/hooks/get_avatar/)
 *  Thread Starter [vl4d](https://wordpress.org/support/users/vl4d/)
 * (@vl4d)
 * [1 year, 7 months ago](https://wordpress.org/support/topic/custom-avatar-7/#post-18085924)
 * thanks i try something like this
 *     ```wp-block-code
       function my_custom_avatar($avatar, $id_or_email, $size, $default, $alt) {    // Get user ID if email or object is provided    if (is_numeric($id_or_email)) {        $user_id = $id_or_email;    } elseif (is_object($id_or_email)) {        // For objects like WP_Comment        $user_id = $id_or_email->user_id;    } else {        $user = get_user_by('email', $id_or_email);        $user_id = $user ? $user->ID : null;    }    // Retrieve custom avatar from user meta (with correct meta_key)    if ($user_id) {        $custom_avatar = get_user_meta($user_id, 'Custom_User_avatar', true);    }    // If a custom avatar is available, return it directly    if (!empty($custom_avatar)) {        $avatar = "<img alt='{$alt}' src='" . esc_url($custom_avatar) . "' class='avatar avatar-{$size} photo' height='{$size}' width='{$size}' />";    }    return $avatar;}add_filter('get_avatar', 'my_custom_avatar', 10, 5);
       ```
   
 * but beacuse i have the _Comments and Users Cache_ on if a user have make a comment
   and after change the avatar its still show the old is this normal??
 *  Plugin Support [gVectors Support](https://wordpress.org/support/users/gvectorssupport/)
 * (@gvectorssupport)
 * [1 year, 7 months ago](https://wordpress.org/support/topic/custom-avatar-7/#post-18090671)
 * Please register and open a new support topic in the [wpDiscuz.com](https://wpdiscuz.com/community/)
   for deeper support.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘custom avatar’ is closed to new replies.

 * ![](https://ps.w.org/wpdiscuz/assets/icon-256x256.png?rev=1076265)
 * [Comments - wpDiscuz](https://wordpress.org/plugins/wpdiscuz/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wpdiscuz/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wpdiscuz/)
 * [Active Topics](https://wordpress.org/support/plugin/wpdiscuz/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wpdiscuz/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wpdiscuz/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [gVectors Support](https://wordpress.org/support/users/gvectorssupport/)
 * Last activity: [1 year, 7 months ago](https://wordpress.org/support/topic/custom-avatar-7/#post-18090671)
 * Status: resolved