10 Useful Code Snippets And Plugins To Spice Up Wordpress Avatar
Spread it!
How well are you using avatar in your wordpress blog? Let see how people spice up avatar section in their wordpress. This entry provides us 10 most useful code snippets and wordpress plugins that help us control, customize our avatar in wordpress better.
Change the Default Gravatar in Wordpress
add_filter( 'avatar_defaults', 'newgravatar' ); function newgravatar ($avatar_defaults) { $myavatar = get_bloginfo('template_directory') . '/images/buildinternet-gravatar.jpg'; $avatar_defaults[$myavatar] = "Build Internet"; return $avatar_defaults; }
By default, if users don’t have gravatar with their email, wordpress gives you an option that can be change the default avatar in Setting>Discussion. However, you can replace or add one more option that default avatar can be replace by your own image.
Source: Build Internet
Using Twitter avatars in comments without plug-ins
First, grab the functions file here.
Then, copy all the content of twittar.php and paste it to your functions.php file
Finally, copy and paste code line below to your comments.php file within the comment loop.
<?php twittar('45', 'default.png', '#e9e9e9', 'twitavatars', 1, 'G'); ?>
Automatically insert author bio on each post
Using WordPress hooks, it can be very easy to modify WordPress variables to fit your needs. In this recipe, I’m going to show you how to use hooks to automatically insert the author bio after each post.
Open your functions.php file and paste the following code. After insert these code, you can customize the css for the author bio box easily.
function get_author_bio ($content=''){ if(!in_category("Community News")) { $post_author_name=get_the_author_meta("display_name"); $post_author_description=get_the_author_meta("description"); $html="<div class='clearfix' id='about_author'>\n"; $html.="<img width='80' height='80' class='avatar' src='http://www.gravatar.com/avatar.php?gravatar_id=".md5(get_the_author_email()). "&default=".urlencode($GLOBALS['defaultgravatar'])."&size=80&r=PG' alt='PG'/>\n"; $html.="<div class='author_text'>\n"; $html.="<h4>Author: <span>".$post_author_name."</span></h4>\n"; $html.= $post_author_description."\n"; $html.="</div>\n"; $html.="<div class='clear'></div>\n"; $html.="</div>"; $content .= $html; } return $content; }
Checking for the Existence of a Gravatar
If you request a Gravatar image and the email you request doesn’t have an account in the Gravatar system it returns a default image to you. In some cases this might not be what you want, instead, you might want to know whether you will get back a real gravatar or if it will just be the default. Sometime, you don’t want to display avatar element instead of default avatar if users don’t have gravatar exists in your email.
Wordpress Codex shows you a trick that check the header response. Return false if code response is not match with 202. Thus, you can use the Boolean value to decide display or not.
<?php function validate_gravatar($email) { // Craft a potential url and test its headers $hash = md5($email); $uri = 'http://www.gravatar.com/avatar/' . $hash . '?d=404'; $headers = @get_headers($uri); if (!preg_match("|200|", $headers[0])) { $has_valid_avatar = FALSE; } else { $has_valid_avatar = TRUE; } return $has_valid_avatar; } ?>
User Avatar Photos in WordPress
WordPress has supported Gravatars for awhile, which is great, but in some cases, you want to display users avatar as their uploaded photos.
First, download and install User Photo plugin, then use code below to display their photo:
if (function_exists('userphoto_the_author_thumbnail')) { userphoto_the_author_thumbnail(); }
Avatar Display for Logged In Users
This simple code help to display the avatar of current logged user.
<?php global $current_user; get_currentuserinfo(); echo get_avatar( $current_user->ID, 128 ); ?>
Add Local Avatar
Adds local (private) avatars for your users. Maybe your users don’t want a global avatar, aren’t IT savvy enough to set a Gravatar up, simply want a private avatar for your blog, or any other reason too…
WP-Gravatar Plugin
This plugin lets you use Gravatar, MyBlogLog, OpenAvatar, Wavatar, Identicon, monsterID or Favico.ico files with your comments. But thats not all, this plugin provides you many features: gives you a Widget with your profile info and your gravatar, gives you the option to show an about the author box with posts shown on single page, let’s you show the Gravatar, OpenAvatar, Wavatar, Identicon, monsterID avatars in the Edit Comment section of your admin pages…
Download: WP-Gravatar
WP-SnapAvatar
When people comment in your blog but they don’t have avatar, such as gravatar… this plugin will allows us to take a snapshot of their website for the replacement.
Download: WP-SnapAvatar
jQuery Comment Preview
Live comment preview without page reboot. Works on jQuery.
Download: jQuery Comment Preview
Related Posts
- 10 Wordpress Plugins To Boost Up Your Theme You Have Ever Known
- Wordpress Hack: Anything Can Be Added Anywhere In The Post Content
- Twitter Trackbacks Widget – A jQuery Plugin
- 5 Useful tools to convert your entire code into Colorized and browsable HTML
- 5 Fresh jQuery Plugins Make You Love Your HTML Forms More
37 User Comments
Trackbacks/Pingbacks
-
-
01. Dec, 2009
[...] from: 10 Useful Code Snippets And Plugins To Spice Up Wordpress Avatar Related [...]
-
-
01. Dec, 2009
[...] This post was mentioned on Twitter by A u d e e and Web Design News, Gaurav Nanda. Gaurav Nanda said: RT @allwebdesign: 10 Useful Code Snippets And Plugins To Spice Up Wordpress Avatar http://bit.ly/8VOKRJ [...]
-
-
01. Dec, 2009
Social comments and analytics for this post…
This post was mentioned on Twitter by allwebdesign: 10 Useful Code Snippets And Plugins To Spice Up Wordpress Avatar http://bit.ly/8VOKRJ...
-
-
01. Dec, 2009
[...] This post was mentioned on Twitter by Studio3k. Studio3k said: RT @cristianvasile: 10 Useful Code Snippets And Plugins To Spice Up Wordpress Avatar http://bit.ly/5m625G [...]
-
-
01. Dec, 2009
WPscoop…
Trackback WPscoop! http://wpscoop.com/Wordpress-Resources/10-Useful-Code-Snippets-And-Plugins-To-Spice-Up-Wordpress-Avatar!…
-
-
01. Dec, 2009
10 Useful Code Snippets And Plugins To Spice Up Wordpress Avatar…
This entry provides us 10 most useful code snippets and wordpress plugin that help you control, customize your avatar in wordpress better.
…
-
-
01. Dec, 2009
[...] more from the original source: 10 Useful Code Snippets And Plugins To Spice Up Wordpress Avatar | AEXT.NET Comments0 Leave a Reply Click here to cancel [...]
-
-
01. Dec, 2009
[...] This post was Twitted by webtechman [...]
-
-
01. Dec, 2009
[...] Read the original: 10 Useful Code Snippets And Plugins To Spice Up Wordpress Avatar | AEXT.NET [...]
-
-
01. Dec, 2009
[...] This post was Twitted by purplehayz [...]
-
-
01. Dec, 2009
[...] 10 Useful Code Snippets And Plugins To Spice Up Wordpress AvatarThis entry provides us 10 most useful code snippets and wordpress plugins that help us control, customize our avatar in wordpress better. Submit More News Tuesday, December 1st, 2009 | Written by: Franco Averta No Comments [...]
-
-
01. Dec, 2009
[...] Read the original article [...]
-
-
01. Dec, 2009
[...] In: Wordpress plugins 2 Dec 2009 Go to Source [...]
-
-
02. Dec, 2009
[...] Read more from the original source: 10 Useful Code Snippets And Plugins To Spice Up Wordpress Avatar | AEXT.NET [...]
-
-
02. Dec, 2009
[...] This post was Twitted by Dustin_Schmidt [...]
-
-
02. Dec, 2009
[...] 10 Useful Code Snippets And Plugins To Spice Up Wordpress Avatar | AEXT.NETaext.net [...]
-
-
03. Dec, 2009
[...] 10 Useful Code Snippets And Plugins To Spice Up Wordpress Avatar | AEXT.NET [...]
-
-
03. Dec, 2009
[...] This post was Twitted by navin_l [...]
-
-
03. Dec, 2009
[...] This post was Twitted by paulsanduleac [...]
-
-
03. Dec, 2009
[...] 10 Useful Code Snippets And Plugins To Spice Up Wordpress Avatar [...]
-
-
04. Dec, 2009
[...] This post was Twitted by ellenbauer [...]
-
-
05. Dec, 2009
[...] WordPress’de Gravatar Özelleştirmek için 10 Kod Parçası [...]
-
-
05. Dec, 2009
[...] 10 Useful Code Snippets And Plugins To Spice Up Wordpress Avatar (aext). Esta entrada nos ofrece 10 fragmentos de código más útil y plugins para WordPress que nos ayudan a controlar, y personalizar nuestro avatar en WordPress. [...]
-
-
06. Dec, 2009
[...] 10 Useful Code Snippets And Plugins To Spice Up Wordpress Avatar | AEXT.NET [...]
-
-
06. Dec, 2009
[...] 10 useful code snippets and plugins to spice up WordPress avatar [...]
-
-
25. Jan, 2010
[...] 10 Useful Code Snippets And Plugins To Spice Up Wordpress Avatar | AEXT.NET (tags: wordpress avatar plugins tips code wordpress-plugins hacks tutorial) [...]
-
-
12. Mar, 2010
[...] 10 Useful Code Snippets And Plugins To Spice Up Wordpress Avatar [...]

















WOW, very useful.
Thanks for your sharing.
thank for the great post
very useful
Nice post Lam! Thanks for sharing this. I’m always looking for more Wordpress snippets that can make my website better.
By the way, I love the design of your blog. Very clean!
Great post can come in handy for the new design. Thnx for sharing.
Thank you guys!
Hi Lam , i enjoyed reading this post. It gave some interesting new insights.
Thank you.
helpful tutorial, thanks for the post..
All the hacks are nice. Thanks for sharing.
Great Post, Lam. Thank you very much.
The code for Avatar Display for Logged In Users.
Do you have a code that will display ALL logged in users?