Last comments

Parrot AR.drone - app for the Iphone

Posted February 26th 2010 by Dan Audne

Gravatar for phpBB3

Posted February 26th 2010 by Dan Audne

Forgot the PM's, so i've updated the article!

Since there are so many web apps that use Gravatars, i.e. wordpress, I thought why not use it in forums too.
So in this tutorial I will show you how to mod phpBB3 so you can let your users choose if they want to upload an avatar to the forum or just use Gravatar if they have it.

In this tutorial we'll be editing these files:

  • includes/functions.php
  • viewtopic.php
  • memberlist.php
  • includes/ucp/ucp_pm_viewmessage.php


Open
includes/functions.php

Find
?>

Before, add
function get_gravatar($mail){
     
     global $user, $config, $phpbb_root_path, $phpEx;
     
     return '<img src="http://www.gravatar.com/avatar.php?gravatar_id='.md5(strtolower($mail)).'&rating=PG&size=90&default=ADD-YOUR-DEFAULT-PICTURE-URL-HERE&size=90" alt="' . ((!empty($user->lang[$alt])) ? $user->lang[$alt] : $alt) . '"';
     
}


Open
viewtopic.php

Find
'avatar' => ($user->optionget('viewavatars')) ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'], $row['user_avatar_height']) : '',

Replace with
'avatar' => !empty($row['user_avatar']) ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'], $row['user_avatar_height']) : get_gravatar($row['user_email']),

Open
memberlist.php

Find
$poster_avatar = get_user_avatar($member['user_avatar'], $member['user_avatar_type'], $member['user_avatar_width'], $member['user_avatar_height']);

Replace with
$poster_avatar = !empty($member['user_avatar']) ? get_user_avatar($member['user_avatar'], $member['user_avatar_type'], $member['user_avatar_width'], $member['user_avatar_height']) : get_gravatar($member['user_email']);

Open
includes/ucp/ucp_pm_viewmessage.php

Find
'AUTHOR_AVATAR'=>
(isset($user_info['avatar'])) ? $user_info['avatar'] : '',


Replace with
'AUTHOR_AVATAR'=>
(!empty($user_info['avatar'])) ? $user_info['avatar'] :
get_gravatar($user_info['user_email']),



Save and close all files!

For the users Gravatar to be shown they must delete their avatar in the UCP, if they have choosen or uploaded one.