WordPress Gravatar Plugin for Multiple Authors
I’ve been looking for a WordPress plugin that provides multi users to show their respective gravatars on their authored posts. Different authors, different gravatars on each post. Unluckily, I have never found one. I don’t know if there exist one for I have minimal access on resources because of f*in WebSense.
Anyway, for me, the simpliest gravatar plugin is the WordPress Gravatar Plugin. It just generates the URL for the source gravatar and it’s up to you where you want to put it on your site. However, the latest available version only supports gravatar for comment authors. What I want is have it to support authors’ gravatars on posts as well.
As I have said “simple”, here’s what I did with the plugin:
- Added a parameter that will verify if the function was called from a post or from the comments.
function gravatar($rating = false, $size = false, $a_post = false, $default = false, $border = false)
- Added a global $authordata variable
- Used $authordata->user_email if gravatar was called from a post
$out = "http://www.gravatar.com/avatar.php?gravatar_id=".md5($comment->comment_author_email);
$out = "http://www.gravatar.com/avatar.php?gravatar_id=".md5($authordata->user_email);
- Called the gravatar function on posts
<img id="gravatar" src="<?php gravatar('R', 40, true); ?>" alt="author's gravatar">
- Called the gravatar function on comments
<img id="gravatar" src="<?php gravatar('R', 50, false); ?>>