• vl4d

    (@vl4d)


    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.png
    how to make the comments system to read this type of avatar and not the deafult wp?

    • This topic was modified 1 month ago by vl4d.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support gVectors Support

    (@gvectorssupport)

    Hi,

    You should use the native WordPress get_avatar hook to implement the custom avatars.

    More info here: https://developer.www.ads-software.com/reference/hooks/get_avatar/

    Thread Starter vl4d

    (@vl4d)

    thanks i try something like this

    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

    (@gvectorssupport)

    Please register and open a new support topic in the wpDiscuz.com for deeper support.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.