displaying avatar on website pages

This forum is now closed as part of retiring phpBB2.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

This forum is now closed due to phpBB2.0 being retired.
Post Reply
jjmas
Registered User
Posts: 3
Joined: Mon Mar 31, 2008 7:52 pm

displaying avatar on website pages

Post by jjmas » Mon Mar 31, 2008 9:13 pm

im using the following code i got from Knowledge Base - phpBB2 Sessions Integration

and im using the following code so far

Code: Select all

<?php
define('IN_PHPBB', true);
$phpbb_root_path = '../forum/';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Example sessions page</title>
<body>
<?php
if($userdata['session_logged_in'])
{
echo('Hi '.$userdata['username'].'! <a href="' . append_sid($phpbb_root_path . 'login.php?logout=true') . '&sid=' .$userdata['session_id'].'">Logout</a>');
}
else
{
?>

Hi Guest!<br />
<form action="<?php echo($phpbb_root_path); ?>login.php" method="post" enctype="multipart/form-data">
Username: <input type="text" name="username"><br />
Password: <input type="password" name="password"><br />
<input type="hidden" name="redirect" value="../">
<input type="submit" value="login" name="login">
</form>
<?php
}

?>
</body>
</html>
and what i want is so that when the user logs in, its displays their avatar, i was trying somethings but none of them worked, i have done this before by reading about this forum a long time ago, but i cant locate it again, so if anyone can help it would be wonderful

User avatar
dellsystem
Former Team Member
Posts: 3879
Joined: Sat Apr 09, 2005 8:54 pm
Location: Montreal
Name: Wendy
Contact:

Re: displaying avatar on website pages

Post by dellsystem » Mon Mar 31, 2008 9:37 pm

AbelaJohnB's Welcome and Avatar on Index MOD has some code that may be useful:

$avatar_img = '';
if ( $userdata['user_avatar_type'] && $userdata['user_allowavatar'] )
{
switch( $userdata['user_avatar_type'] )
{
case USER_AVATAR_UPLOAD:
$avatar_img = ( $board_config['allow_avatar_upload'] ) ? '<img src="' . $board_config['avatar_path'] . '/' . $userdata['user_avatar'] . '" alt="" border="0" />' : '';
break;
case USER_AVATAR_REMOTE:
$avatar_img = ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $userdata['user_avatar'] . '" alt="" border="0" />' : '';
break;
case USER_AVATAR_GALLERY:
$avatar_img = ( $board_config['allow_avatar_local'] ) ? '<img src="' . $board_config['avatar_gallery_path'] . '/' . $userdata['user_avatar'] . '" alt="" border="0" />' : '';
break;
}
}

and you can just echo $avatar_img.

This topic would be more suited for MOD Writers, so I'll move it there in case that doesn't work :)
Former moderator and website team member | My MODs, and more (GitHub)

jjmas
Registered User
Posts: 3
Joined: Mon Mar 31, 2008 7:52 pm

Re: displaying avatar on website pages

Post by jjmas » Tue Apr 01, 2008 12:51 am

thanks ill look into that, it looks very helpful =)

Post Reply

Return to “[2.0.x] MOD Writers Discussion”