Simple Machines Community Forum

General Community => Scripting Help => Aiheen aloitti: MadnessRed - tammikuu 24, 2008, 05:28:04 IP

Otsikko: Display photo
Kirjoitti: MadnessRed - tammikuu 24, 2008, 05:28:04 IP
OK, heres the thing, i want to show the profile picture on the website. Along with where is says welcome ect.

Below is what I currently have

[php]
<?php
if ($context['user']['is_guest'])
{
ssi_login();
}
else
{
//You can show other stuff here.  Like ssi_welcome().  That will show a welcome message like.
ssi_welcome(); flush();
echo 
"<br>";
echo 
"<a href=forum/index.php?action=profile target=_new>Edit Profile</a>";
echo 
"<br>";
ssi_logout();
}
?>

[/php]


which shows this

LainaaHey, Anthony, you have 0 messages, 0 are new.
Edit Profile
Logout

What I want is to have my profile picture shown below that. Any help would be welcome. Thanks Anthony.
Otsikko: Re: Display photo
Kirjoitti: jamesk - tammikuu 24, 2008, 05:32:24 IP
Add:

echo $context['user']['avatar']['image'];
Otsikko: Re: Display photo
Kirjoitti: MadnessRed - tammikuu 24, 2008, 05:38:07 IP
nice, thanks, also is there anyway to set the size? so make it 100 x 100 for example

and can I get a name so I can like write hello #name# you will be redirected soon.

I have got this so far however it wont redirect to the forum.

[php]<?php
if ($context['user']['is_guest'])
{
echo "<META HTTP-EQUIV=Refresh
      CONTENT=3; URL=smflogin.php>"
;
}

else
{
echo "<META HTTP-EQUIV=Refresh
      CONTENT=3; URL=forum/index.php>"
;
}
?>



<?php include("includetop.php"); ?>


<?php
if ($context['user']['is_guest'])
{
echo "Hello, you need to login. You will be redirect in 3 seconds.";
}
else
{
echo "Hello";
echo $user_profile[$memID]['memberName'];
echo ". You will be redirected in 3 seconds.";
}
?>



<?php include("includebottom.php"); ?>[/php]
Otsikko: Re: Display photo
Kirjoitti: jamesk - tammikuu 24, 2008, 06:08:41 IP
Although it may skew the images, you can set the image size:

echo '<img src="', $context['user']['avatar']['href'], ' "width="100" height="100">';

As for name, you can:

echo $context['user']['name']

but you already have that in the ssi_welcome();

Not sure about the re-direct... This may or may not work...I really haven't tried or thought it through (based on http://support.simplemachines.org/function_db/index.php?action=view_function;function=710):


if ($context['user']['is_guest'])
{
    redirectexit('action=login');
}

else
{
redirectexit('action=forum');

}




Otsikko: Re: Display photo
Kirjoitti: MadnessRed - tammikuu 24, 2008, 06:19:27 IP
ok thanks, managed to edit the link as an "if-else" so in the end i could manage without redirect. if i only fix the width the image should stay in preportian? adn thanks for the name, where do you get this info from?
Otsikko: Re: Display photo
Kirjoitti: jamesk - tammikuu 24, 2008, 06:24:06 IP
I just looked at the SSI.php file, but I learned a lot from the FAQ:

http://www.simplemachines.org/community/index.php?topic=14906.0
Otsikko: Re: Display photo
Kirjoitti: MadnessRed - tammikuu 24, 2008, 06:26:47 IP
ok, thanks for all your help