Wordpress: Change profile picture wihout plugin and gravatar

- Step 1: go to wp-content/themes/yourtheme/functions.php
- write:
add_filter( 'get_avatar', 'ChangeAdminProfileIfNot', 10, 5 );
function ChangeAdminProfileIfNot( $avatar = '', $id_or_email, $size = 96, $default = '', $alt = '' ) {
if( "user_has_uploaded_a_local_avatar") {
$avatar = "<img src='your image path' class='avatar avatar-{$size} photo' height='{$size}' width='{$size}'";
}
return $avatar;
}
Note:
user_has_uploaded_a_local_avatar
If you want to change profile picture only for admin
then write:
add_filter( 'get_avatar', 'ChangeAdminProfileIfNot', 10, 5 );
function ChangeAdminProfileIfNot( $avatar = '', $id_or_email, $size = 96, $default = '', $alt = '' ) {
if( "user_has_uploaded_a_local_avatar" && strpos($avatar, '524839ea4d48eb11da1325dc1bfccc14') !== FALSE) {
$avatar = "<img src='new image path' class='avatar avatar-{$size} photo' height='{$size}' width='{$size}'";
}
return $avatar;
}
this is my admin image id. find your image id. You can check your image id using inspect element.
Comments
Post a Comment