Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: danskmacabre on July 03, 2006, 03:15:20 AM

Title: How to include the "check if user logged in" code in custom code.
Post by: danskmacabre on July 03, 2006, 03:15:20 AM
Basically, I'm coding a database maintenance page for a wargame I'm running online, partially using SMF forums for information.

The code I want to generate should check if the user is currently logged in and if so use those user details to show appropriate content to the specific user.

I know I can just scan the code and find the appropriate part eventually, but if anyone has any experience with this, then advice would be appreciated.


Title: Re: How to include the "check if user logged in" code in custom code.
Post by: Elmacik on July 03, 2006, 03:37:14 AM

<?php
include("/absolute/forum/path/SSI.php");
if (
$context['user']['is_logged'])
echo
' Hi User! ';
if (
$context['user']['is_admin'])
echo
' Administration options ';
if (
$context['user']['is_guest'])       # or !$context[user']['is_logged'] can be used instead..
echo ' You are a guest, please login or register. ';
?>


This is the easier way.
Title: Re: How to include the "check if user logged in" code in custom code.
Post by: danskmacabre on July 03, 2006, 10:40:05 AM
oooh that's perfect..
Thanks for that.