'In This Discussion' user avatars not using Gravatar
Hi,
I installed the 'Gravatar' plugin which Implements Gravatar avatars for all users who haven't uploaded their own custom profile picture on my forum.
Then I installed and modded the 'In This Discussion' plugin to show the avatars of users participating in a discussion, instead of their names (i.e., user avatar instead of text).
I did it by editing '/vanilla-root-directory/plugins/VanillaInThisDiscussion/class.inthisdiscussionmodule.php' to use the following code:
<div class="PhotoGrid"> <?php foreach ($this->_UserData->Result() as $User) { ?> <?php echo UserPhoto($User); ?> <?php } ?>
The problem is, the 'In This Discussion' panel box shows user avatars but doesn't use their Gravtar — it only uses either the avatar uploaded by the user or the default forum avatar.
Why is this happening? What am I possibly doing wrong? Should I be using something else instead of <?php echo UserPhoto($User); ?>
??
Best Answer
-
peregrine MVP
The problem I have is I haven't signed up for gravatars but was just checking the url and other variables. But one more attempt.
It seems to be missing the email in the object you are sending. So the sql in the top of the "class.inthisdiscussionmodule.php" needs to be changed.
I hope it will work with this fix - I added u.Email and it looks like it would work based on my echo statements.
Select('u.UserID, u.Name, u.Photo, u.Email')I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
1
Answers
are you using any other plugin that's using the UserPhoto Function?
indexphotos?
check the content of the $User
and compare it to the $User of the one u edited in inthisdiscussionmodule.php
there might be a missing attribute.
Check out my other Plugins here
@Aolee : I checked it out. It uses:
and:
I tried various combinations of them with mine. None worked.
Just an idea. In any event it will show you how it works.
identify where the gravatar icons are and build a link to them that is basically what User Photo does.
you could break out the components to see what the value of $PhotoUrl
in library/core/functions.render.php to get an idea.
write your link and anchor based on the value of $url (with the gravatar.com) in function of plugins/gravatar/
so instead of echo UserPhoto($User);
echo (the linked image you built yourself)
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
also maybe this will help you
http://en.gravatar.com/site/implement/hash/
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
@peregrine : Thanks for trying to help. Yeah, I guess the problem is with hashing the email address. I will check it and let you know if it works. Thanks.
@peregrine : And finally, after trying for at least one whole day, I give up. It was close. The 'In This Discussion' plugin was showing the user uploaded avatar. But I could not get it to show user's gravatar.
If you decide to return to it. I wasn't sure if gravatars work anywhere on your site besides the default gravitar icon? I assume your phpinfo shows md5 support.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
@peregrine: Take a look at this thread. User 'Aahan' has uploaded his own avatar, so it shows that. User 'Krish' hasn't, so it shows his Gravatar.
EDIT: I have disabled the 'In This Discussion' plugin in the sidebar (Panel).
I copied from your site hard coded it into this discussions on my site and it showed the same gravatar as on your site.
next I just replaced the function with this code.
And it worked. Just swap this into the discussion module. It really should work since you have the gravatars working in one place.
I am not using the vanilla icons plugin only the gravatar plugin.
--
If it doesn't work for you goto the gravatar.php plugin - echo or write to a message log.
Insert :
echo $Url;
before this statement at the bottom of the plugin
if (C('Plugins.Gravatar.UseVanillicon', FALSE))
and echo $Url right before the return and compare them.
At least that way you see if it is hitting that plugin - which it needs to do.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
Using the code you provided gives me this error:
I am using Gravatar plugin only. I don't use Vanillicons.
I will check the Gravatar plugin... Thanks.
I checked that. If
echo $Url;
is added beforeif (C('Plugins.Gravatar.UseVanillicon', FALSE))
it shows this: http://www.gravatar.com/avatar.php?gravatar_id=d41d8cd98f00b204e9800998ecf8427e&size=50If
echo $Url;
is added before the return, it shows this: http://www.gravatar.com/avatar.php?gravatar_id=d41d8cd98f00b204e9800998ecf8427e&size=50&default=http://groups.boygeek.in/plugins/Gravatar/default.gifSo, it isn't working, right?
EDIT: And by the way, I have enabled the 'In This Discussion' plugin now. You can take a look at it here — in the sidebar (panel).
I modified your code to this to that it retains proper styling:
Are you sure that user has a gravatar signed up for that e-mail addess.
same format as the final url with a different md5 conversion.
It appears to me each user has to sign up for a gravatar, it is not the same as vanilla icons which will work for all users.
this works same url format (your orginal hash that works on your site for that user.
http://www.gravatar.com/avatar.php?gravatar_id=951ae80ef8b74221dc49b5090271fbbe&size=50&default
=http%3A%2F%2Fgroups.boygeek.in%2Fplugins%2FGravatar%2Fdefault.gif
what's odd is the same user has two different hashes try echoing the $User in the same places.
and see if its not picking up the user correctly. same with the e-mail.
(from the comment)
http://www.gravatar.com/avatar.php?gravatar_id=951ae80ef8b74221dc49b5090271fbbe&size=50&default=http://groups.boygeek.in/plugins/Gravatar/default.gif"
(from in the discussions
http://www.gravatar.com/avatar.php?gravatar_id=d41d8cd98f00b204e9800998ecf8427e&size=50&default=http://groups.boygeek.in/plugins/Gravatar/default.gif"
from your profile it shows this
http://www.gravatar.com/avatar.php?gravatar_id=951ae80ef8b74221dc49b5090271fbbe&size=50&default=http://groups.boygeek.in/plugins/Gravatar/default.gif"
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
I see the problem. Two different $User one an object with e-mail and the other not.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
@peregrine : I was away, and just got back. So, do you know the fix now?
The problem I have is I haven't signed up for gravatars but was just checking the url and other variables. But one more attempt.
It seems to be missing the email in the object you are sending. So the sql in the top of the "class.inthisdiscussionmodule.php" needs to be changed.
I hope it will work with this fix - I added u.Email and it looks like it would work based on my echo statements.
Select('u.UserID, u.Name, u.Photo, u.Email')
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
OMG! @peregrine you got it. That's solves the problem! I will write a full how-to for everyone shortly. Thanks a lot peregrine! (You can check it here.)
Glad it helped . I appreciate and I am sure others will appreciate your how-to.
We need more complete how-to's in my opinion.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
How to show Avatars (Photo / Gravatar) of Users participating in a discussion?
[1] First enable the 'In This Discussion' and 'Gravatar' plugins on your forum
[2] Open '/vanilla-forum-root/plugins/VanillaInThisDiscussion/class.inthisdiscussionmodule.php' and replace this block of code:
With this:
You've thereby modded the 'In This Discussion' plugin to output user avatar (the photo he uploaded to your forum, and if he hasn't, his Gravatar) instead of the username and date.
[3] Now in the same file, change this line:
to this:
That's it. And now your discussions should show something like this in the panel (sidebar) — the image below shows that 2 users are participating in the discussion:
BEFORE:
AFTER:
Happy modding! All credit to peregrine.
@peregrine : Thanks for your time.
nice.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
that's the missing attribute "u.Email".