Home Forums Plugin Support WP User Frontend Pro Check if user has avatar uploaded in userfrontend pro

This topic is: not resolved

This topic contains 9 replies, has 2 voices, and was last updated by  nabeel 4 years, 6 months ago.

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #34006

    nabeel
    Member
    Post count: 29

    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');
    } ?> 
    #34022

    towhid
    Participant
    Post count: 4505

    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 ๐Ÿ™‚

    #34046

    nabeel
    Member
    Post count: 29

    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");
    } ?>
    #34339

    towhid
    Participant
    Post count: 4505

    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 ๐Ÿ™‚

    #34367

    nabeel
    Member
    Post count: 29
    This reply has been marked as private.
    #34384

    nabeel
    Member
    Post count: 29
    This reply has been marked as private.
    #34512

    towhid
    Participant
    Post count: 4505

    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 ๐Ÿ™‚

    #34516

    nabeel
    Member
    Post count: 29

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

    #34575

    towhid
    Participant
    Post count: 4505

    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 ๐Ÿ™‚

    #34604

    nabeel
    Member
    Post count: 29
    This reply has been marked as private.
Viewing 10 posts - 1 through 10 (of 10 total)

The topic ‘Check if user has avatar uploaded in userfrontend pro’ is closed to new replies.