Skip Navigation

[Resolved] Gravatar Profile Picture in Post View

This support ticket is created 2 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 6 replies, has 2 voices.

Last updated by richardG-4 2 years, 6 months ago.

Assisted by: Luo Yang.

Author
Posts
#2351117

Tell us what you are trying to do? Trying to display the author gravatar image in a View

Is there any documentation that you are following? I tried the following support thread, and it seems like it almost worked, but the images are coming up as the default image, not the one I selected on Gravatar:
https://toolset.com/forums/topic/including-gravatars-in-views/#post-17483

I have tried the following shortcodes:

[wpv-gravatar email="[types field='company-email' raw='true'][/types]"] (this one came from the above documentation, and I included the function in my Toolset custom code, and activated the snippet)
[types usermeta='profile-picture' title='%%TITLE%%' alt='%%ALT%%' size='medium' resize='proportional' user_is_author='true'][/types] (displays nothing)
[types usermeta='profile-picture'][/types] (displays nothing)
[wpv-user field="profile_picture" size="400px"]

The last one obviously just shows a picture of my Gravatar profile picture, so I know it could be working, it's just not linking to the author of the post.

I considered the option of doing a custom user field, and started setting that up, but I'd really rather not have thousands of profile images on my server, so using Gravatar is the way I'd like to go.

What is the link to your site?

The page where the posts are displayed is private, but I can give access if needed.

#2351335

Hello,

You are referring very old ticket, in the latest version of Toolset plugins, in order to use shortcode in shortcode feature, you need to register the custom shortcode name here:
Dashboard-> Toolset-> Settings-> Frontend:
in section "Third-party shortcode arguments", add the custom shortcode name: wpv-gravatar
And test again

More help:
https://toolset.com/documentation/legacy-features/views-plugin/shortcodes-within-shortcodes/

#2352113
gravatar.JPG

Thanks, I've done that now. I'm a little surprised there isn't an built-in solution, is Gravatar not commonly used for user profile pictures?

I seem to be missing something, the images are still coming out as a default image. I'll share a screenshot of what I'm seeing. I know the Gravatar image works, because I can show my own profile picture, just not the author's profile picture.

I've tried changing the quotation marks from " to ' but that didn't seem to do anything.

I also tries the following variations of the types field:

 [wpv-gravatar email='[types field="company-email" raw="true"][/types]']
 [wpv-gravatar email='[types field="primary-email" raw="true"][/types]']
 [wpv-gravatar email='[types field="email" raw="true"][/types]']

Is there something wrong with the old shortcode? Here is my snippet:

<?php
/**
 * Allow Gravatar profile image in Views
 */

toolset_snippet_security_check() or die( 'Direct access is not allowed' );

// Put the code of your snippet below this comment.

add_shortcode('wpv-gravatar', 'my_gravatar');
function my_gravatar($atts) {
   return get_avatar( $atts['email'] );
}	
#2352311

I have tried it in my localhost with a fresh WP installation + the latest version of Toolset plugins, it works fine.

How you create those custom fields? are they custom post fields or user fields?
If they are custom user fields created with Types plugin, you need to follow our document to display the fields value, for exmaple:
[types usermeta="primary-email" output="raw"][/types]
And display the gravatar, like this:
[wpv-gravatar email='[types usermeta="primary-email" output="raw"][/types]']

More help:
https://toolset.com/documentation/customizing-sites-using-php/functions/#email

#2352795

Oh, I thought it would be pulling in the default WordPress field for the user's Gravatar image, is that not the case? I mean, every user already has that field built into their account, right? I just need to display that image field for the author of the post.

#2353345

There might be some misunderstandings, and you did not answer my above question:

How you create those custom fields? are they custom post fields or user fields?

Please elaborate the questions with more details:
I just need to display that image field for the author of the post.
If you want to display the custom image field, please try Types shortcode:
https://toolset.com/documentation/customizing-sites-using-php/functions/#image

If you want to display Gravatar of custom user email field, you can try custom shortcode [wpv-gravatar] as I mentioned above:
https://toolset.com/forums/topic/gravatar-profile-picture-in-post-view/#post-2352311
Here is the document about WordPress Gravatars:
https://wordpress.org/support/article/how-to-use-gravatars/

For your reference.

#2353427

Sorry about the confusion , but I figured it out!

After registering the shortcode per your instruction, I was able to call the correct image for an author's Gravatar by using the following shortcode in the View:

[wpv-gravatar email='[wpv-post-author format="meta" meta="email"]']