Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

graemebryson5 on "Custom Avatar Shortcode"

$
0
0

I'm using the following shortcode to pull in user avatars for a front-end dashboard in conjunction with 'WP User Avatar', which allows users to set their own avatar. I've set a new avatar for myself, yet I'm still seeing the default Mystery Man.

I wanted to know if anyone could perhaps spot any issues/conflicts that would stop the custom avatar being displayed? I'm completely stumped, so would massively appreciate some opinions.

// User Avatar
add_shortcode( 'current-avatar' , 'ss_get_current_avatar' );
function ss_get_current_avatar(){
    $user = wp_get_current_user();
    echo get_avatar( $id_or_email, $size, $default, $alt );
}

// Add class to avatar
add_filter('get_avatar','add_gravatar_class');

function add_gravatar_class($class) {
    $class = str_replace("class='avatar", "class='avatar welcome_avatar", $class);
    return $class;
}

Viewing all articles
Browse latest Browse all 8245

Trending Articles