Check if user has avatar uploaded in userfrontend pro

This topic contains 9 reply and 2 voices, and was last updated by nabeel 9 years, 2 months ago
Viewing 9 Posts - 1 through 9 (of 9 total)
Author Posts
January 13, 2015 at 9:17 am 34006
nabeel My code is not working.. with or without avatar.. it always shows 1111
<?php
$image = get_avatar( get_the_author_meta( 'ID' ));
if (!empty($image)) {
 echo ('1111');
} else {
 echo ('2222');
} ?> 
January 13, 2015 at 11:55 am 34022
towhid towhid

Hello Nabeel,

Please use the following code:

$user_avatar = get_user_meta( $user->ID, 'user_avatar', true );
    if ( empty( $user_avatar ) ) {
        return $avatar;
    }

Hope it will help you to get user avatar.

Thank You 🙂

January 13, 2015 at 2:36 pm 34046
nabeel nabeel

is this correct? because im only getting 111.. is it because of the gravatar default image?

has avatar: http://pinoyalbums.com/author/admin/
no avatar: http://pinoyalbums.com/author/Bella/

<?php
$user_avatar = get_user_meta( $user->ID, 'user_avatar', true );
if ( empty( $user_avatar ) ) {
echo ("111");
} else {
echo ("222");
} ?>
January 17, 2015 at 1:51 pm 34339
towhid towhid

Hello Nabeel,

Sorry for late reply. Please upload an avatar for Bella user then check avatar appear or not and let me know the result.

Thank You 🙂

January 17, 2015 at 7:11 pm 34367
nabeel nabeel This reply has been marked as private.
January 17, 2015 at 8:01 pm 34384
nabeel nabeel This reply has been marked as private.
January 19, 2015 at 3:45 pm 34512
towhid towhid

Hello Nabeel,

Can you please try following code in you template and let me know the result.

$user_id = get_current_user_id();
echo get_avatar( $user_id, 128 );

Thank You 🙂

January 19, 2015 at 4:35 pm 34516
nabeel nabeel

im getting id “1”
admin’s avatar on all accounts

January 20, 2015 at 12:22 pm 34575
towhid towhid

Hello Nabeel,

I have tested this code and it is working fine for me. Can you send me a screenshot the code you have written in a php file.

Thank You 🙂

January 20, 2015 at 3:12 pm 34604
nabeel nabeel This reply has been marked as private.
Viewing 9 Posts - 1 through 9 (of 9 total)