• I have user accounts with avatars uploaded but in the custom profile page I built, I use the shortcode:[avatar]

    It just shows the default image instead of the user’s own profile image.

    Is this a bug or am I using the shortcode wrong? I want the shortcode to display the user’s own avatar.

    Another theory is that maybe caching is causing problems… any known issues related to caching?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter LilGames

    (@lilgames)

    HELLO?!

    Hi, did you read the following URL Installation? It provides a lot of information which I think it will help you with your question.

    Regards

    Thread Starter LilGames

    (@lilgames)

    Yes I did read it (multiple times now). If I understand correctly, the shortcode [avatar] will only show the AUTHOR of the page. I want to show the avatar of the currently logged in USER. Is this possible?

    Yes that is correct, the shortcode [avatar] will only show the author of the page. Do you know what your theme is currently using? Is it using author id or user id? Check the FAQ questions as well. I have not played around with this myself.

    zfiske

    (@zfiske)

    You can fix this by going to the shortcode template found at wp-user-avatar/includes/class-wp-user-avatar-shortcode.php and replacing the instance of the $user_id with the following code:

    $user_id = get_current_user_id();

    That’s it! You should see the current users uploaded image in the display avatar shortcode.

    Let me know if it works for you.

    Thread Starter LilGames

    (@lilgames)

    Just what I was looking for. Thank you zfiske!!

    Prima

    (@bl0gm4n)

    Just what I was looking for too. Thank you zfiske!!

    I put comment here, so I can visit this thread easily thank very much…. again zfiske!!

    Prima

    (@bl0gm4n)

    hy can you make script add_filter or anything, so i can put on themes functions.php.

    I am afraid if plugin get updated the code will lost.

    Please ??

    Prima

    (@bl0gm4n)

    // WP USER AVATAR GET CURRENT IMAGE
    function wpua_current_user_avatar() {
    
    $user_id = get_current_user_id();
    	return get_wp_user_avatar($user_id, 'thumbnail');
      
    }
    add_shortcode( 'wpua-avatar', 'wpua_current_user_avatar' );

    Hy i found the solution,
    hy maybe you can use this in your child theme functions.php, and use [wpua-avatar] shortcode.

    Sharing is caring ??

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘User’s avatar via shortcode is always the default’ is closed to new replies.