10 Useful Code Snippets And Plugins To Spice Up Wordpress Avatar

10 Useful Code Snippets And Plugins To Spice Up Wordpress Avatar


Spread it!

  • Share

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

mystery-man-icon-intro
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'); ?>

Source: WP Recipes

Automatically insert author bio on each post

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;

}

Source: AEXT.NET

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;
}

?>

Source: Wordpress Codex

User Avatar Photos in WordPress

userphoto_wordpress_plugin

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();
        
    }

Source: D’Arcy Norman dot net

Avatar Display for Logged In Users

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

screenshot-3

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…

Download: Add Local Avatar

WP-Gravatar Plugin

screenshot-2

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

screenshot-4

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

screenshot-1

Live comment preview without page reboot. Works on jQuery.

Download: jQuery Comment Preview

  • Digg This Post
  • Tweet This Post
  • Stumble This Post
  • Submit This Post To Delicious
  • Submit This Post To Reddit
  • Submit This Post To Mixx
  • Share on your Facebook
  • Submit this post to Dzone
  • Submit this post to Designbump
  • Submit this post to TheWebBlend

Author: Lam Nguyen

I'm Lam Nguyen, a 21 year old web developer writing about everything related to web design. I am owner of AEXT.NET and WhoFreelance.com Web Community News. You can catch me on twitter.


37 User Comments

  1. YongWei 01. Dec, 2009 at 2:07 am #

    WOW, very useful.
    Thanks for your sharing. :)

  2. designfollow 01. Dec, 2009 at 6:57 am #

    thank for the great post

    very useful

  3. Design Informer 01. Dec, 2009 at 7:41 pm #

    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!

  4. Shurandy Thode 01. Dec, 2009 at 8:00 pm #

    Great post can come in handy for the new design. Thnx for sharing.

  5. Zugvogel 03. Dec, 2009 at 9:07 am #

    Hi Lam , i enjoyed reading this post. It gave some interesting new insights.

    Thank you.

  6. joyoge bookmark 11. Dec, 2009 at 9:35 am #

    helpful tutorial, thanks for the post..

  7. Pavan Somu 18. Dec, 2009 at 1:02 am #

    All the hacks are nice. Thanks for sharing.

  8. Tips Menulis Online 11. Feb, 2010 at 12:29 am #

    Great Post, Lam. Thank you very much.

  9. diana 25. Feb, 2010 at 4:38 pm #

    The code for Avatar Display for Logged In Users.
    Do you have a code that will display ALL logged in users?

Trackbacks/Pingbacks

  1. 10 Useful Code Snippets And Plugins To Spice Up Wordpress Avatar | ShareFavorite - 01. Dec, 2009

    [...] from:  10 Useful Code Snippets And Plugins To Spice Up Wordpress Avatar Related [...]

  2. Tweets that mention 10 Useful Code Snippets And Plugins To Spice Up Wordpress Avatar | AEXT.NET -- Topsy.com - 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 [...]

  3. uberVU - social comments - 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...

  4. Tweets that mention 10 Useful Code Snippets And Plugins To Spice Up Wordpress Avatar | AEXT.NET -- Topsy.com - 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 [...]

  5. WPscoop - 01. Dec, 2009

    WPscoop…

    Trackback WPscoop! http://wpscoop.com/Wordpress-Resources/10-Useful-Code-Snippets-And-Plugins-To-Spice-Up-Wordpress-Avatar!…

  6. CSS Brigit | 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.

  7. 10 Useful Code Snippets And Plugins To Spice Up Wordpress Avatar | AEXT.NET - 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 [...]

  8. Twitted by webtechman - 01. Dec, 2009

    [...] This post was Twitted by webtechman [...]

  9. 10 Useful Code Snippets And Plugins To Spice Up Wordpress Avatar | AEXT.NET | WordPress News - 01. Dec, 2009

    [...] Read the original: 10 Useful Code Snippets And Plugins To Spice Up Wordpress Avatar | AEXT.NET [...]

  10. Twitted by purplehayz - 01. Dec, 2009

    [...] This post was Twitted by purplehayz [...]

  11. 01-12-09(18:07:26) | Concept Dezain - 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 [...]

  12. 10 Useful Code Snippets And Plugins To Spice Up Wordpress Avatar | favSHARE.net - 01. Dec, 2009

    [...] Read the original article [...]

  13. 10 Useful Code Snippets And Plugins To Spice Up Wordpress Avatar | AEXT.NET | Squico - 01. Dec, 2009

    [...] In: Wordpress plugins 2 Dec 2009 Go to Source [...]

  14. 10 Useful Code Snippets And Plugins To Spice Up Wordpress Avatar | AEXT.NET | WpMash - WordPress News - 02. Dec, 2009

    [...] Read more from the original source: 10 Useful Code Snippets And Plugins To Spice Up Wordpress Avatar | AEXT.NET [...]

  15. Twitted by Dustin_Schmidt - 02. Dec, 2009

    [...] This post was Twitted by Dustin_Schmidt [...]

  16. 10 Useful Code Snippets And Plugins To Spice Up Wordpress Avatar | AEXT.NET « Netcrema – creme de la social news via digg + delicious + stumpleupon + reddit - 02. Dec, 2009

    [...] 10 Useful Code Snippets And Plugins To Spice Up Wordpress Avatar | AEXT.NETaext.net [...]

  17. Mes favoris du 2-12-09 au 3-12-09 - 03. Dec, 2009

    [...] 10 Useful Code Snippets And Plugins To Spice Up Wordpress Avatar | AEXT.NET  [...]

  18. Twitted by navin_l - 03. Dec, 2009

    [...] This post was Twitted by navin_l [...]

  19. Twitted by paulsanduleac - 03. Dec, 2009

    [...] This post was Twitted by paulsanduleac [...]

  20. 10 Useful Code Snippets And Plugins To Spice Up Wordpress Avatar | Design Newz - 03. Dec, 2009

    [...] 10 Useful Code Snippets And Plugins To Spice Up Wordpress Avatar [...]

  21. Twitted by ellenbauer - 04. Dec, 2009

    [...] This post was Twitted by ellenbauer [...]

  22. Haftalık Derleme – 3 » Müjdat Korkmaz: Blog - 05. Dec, 2009

    [...] WordPress’de Gravatar Özelleştirmek için 10 Kod Parçası [...]

  23. Enlaces semanales que no he publicado (41) | Cosas sencillas - 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. [...]

  24. vhe74′Stuff » Bookmarks de la semaine (weekly) - 06. Dec, 2009

    [...] 10 Useful Code Snippets And Plugins To Spice Up Wordpress Avatar | AEXT.NET [...]

  25. Notable Tech Posts – 2009.12.06 | The Life of Lew Ayotte - 06. Dec, 2009

    [...] 10 useful code snippets and plugins to spice up WordPress avatar [...]

  26. links for 2010-01-25 at DeStructUred Blog - 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) [...]

  27. Quick Tip: Highlight Author Comments in WordPress – The Right Way | Web Development News - 12. Mar, 2010

    [...] 10 Useful Code Snippets And Plugins To Spice Up Wordpress Avatar [...]

Leave a Reply

CommentLuv Enabled