Sticky Features for your Blog Network with WordPress MU 2.8: Part 2

5 min read

Community features—gravatars

Gravatars are Globally Recognized Avatars. They allow people to carry the same avatar from site to site without having to register at each site and take the time to upload an image. Gravatars are supported by IntenseDebate by default. If a user has a gravatar and gives the email address that the gravatar is tied to when they make a comments, then the gravatar will be displayed beside that comment. Since version 2.5, WordPress MU has had gravatar support built in. Let’s add gravatars to our post pages.

Time for action – gravatars in WordPress MU

  1. Open your theme’s index.php file. In our case we are editng the Blue Zinfandel theme.
  2. Find the secton that begins with < div class=”contentdate” > .
  3. Remove all markup up to the closing tag and insert the following code:
    $email = $authordata->user_email;
    $hash = md5($email);
    $uri = '' . $hash . '?d=identicon&r
    $headers = wp_get_http_headers($uri);
    if (!is_array($headers)) :
    echo "<h3>";
    echo the_time('M');
    echo "</h3><h4>";
    echo the_time('j');
    echo "</h4>";Stcky Features for your Blog Network
    [ 142 ] elseif (isset($headers["content-disposition"]) ) :
    echo get_avatar( $authordata->user_email, $size = '50') ;
    else :
    echo "<h3>";
    echo the_time('M');
    echo "</h3><h4>";
    echo the_time('j');
    echo "</h4>";
  4. Save and upload the file.
  5. If you wish to use gravatars on user blogs, you will also need to edit the user’s version of the theme file.
  6. Now, if a post author has a gravatar, it will be displayed in the title secton of their posts. If not, the default Date of Post box will appear instead.

What just happened?

We have used the built-in WordPress MU gravatars function to display a member’s gravatar in the title section of any posts they make.

As the default No Gravatar Set image is rather boring, our code checks to see if the author in question has a gravatar. If the author does not, or if the Gravatars web site is not accessible for any reason, then we display the normal post date icon instead.

Gravatars provide a way for people to carry their identity from site to site. Showing a recognizable face for your site’s authors builds recognition among readers and helps readers and blog authors to build a relationship with each other.

You might be wondering why the output in the previous code is broken into several echo statements. I have chosen that method purely because I find it more readable. You could save yourself some typing if you built an echo statement similar to this one:

echo "<h3>". the_time('M')."</h3>"

Have a go hero – gravatars and themes

The code used to edit the SlayerCafe blog theme was very simplistic. The theme you are using for your site may be structured differently.

In the theme for the SlayerCafe, the calendar icon that shows the date of the latest post is coded into the CSS file. The change I have made to the index.php file does not prevent the calendar icon from being loaded. The gravatar image simply loads over the top of it.

Try reworking the theme file to correct this. One way to do so would be to create a copy of the contentdate class in the styles.css file, which does not load the calendar image. Call the new class contentgravatar and then create different < div > tags to be displayed depending on whether you wish to show the calendar or the gravatar.

Encouraging sign-ups with downloads for members only

If you offer file downloads, restricting some of them to only members is a good way to encourage people to sign up. It is a good idea to offer some file downloads to visitors who are just passing through so that you can build up their trust, as some people are uncomfortable giving out their email address to an unknown web site. Also, some people do not want to take the time to register to download a file, especially if they don’t know if it is going to be a worthwhile download.

A good compromise is to offer some files to everyone and other files for members only, or to offer some content on your blog and then a download in a more convenient form.

As an example, some of the Watchers on SlayerCafe could run tutorials about demon identification and slaying techniques. They may offer text and image versions as blog posts, with an MP3 version of the lesson that registered Slayers could download to listen to while they are on patrol. This is likely to have a high conversion rate in terms of registrations; the visiting Slayers will hopefully be impressed by the quality of the information in the tutorials and want to download the audio version.

One useful plugin that restricts downloads to registered users only is the User Only Downloads plugin available at This plugin is very easy to use. For some reason the author uploaded the plugin to WPMU Dev as a text file, so you will need to rename it to a .php file before you can use it. Just upload the renamed file to your mu-plugins folder and tell your users that they can restrict file downloads to members only by using the following tag in their posts:

[user_download URL]

Logged in users will see a download link, while everyone else will see a bold message telling them that they need to be logged in to download files.



Please enter your comment!
Please enter your name here