SimplePortal
Customization => Custom Coding => Topic started by: efimomax on September 06, 2009, 07:27:04 AM
-
Hi there,
I'll try to make a custom php page in SimplePortal.
This page must show some info depending user rights/group (actually admin or not).
But i've some mystic things....
this code is work (calling the SSI function):
<?php ssi_welcome(); ?>
but this is don't work :( Always show that i am not admin (do not metter admin i am or not)....
<?php
if ($context['allow_admin'])
{
echo
'<h5>Hello, ', $context['user']['name'], '!</h5>
Here goes info for administrators';
}
else
{
echo
'<h5>You are not admin</h5>';
}
?>
Anybody can help me with this?
Looks like SSI.php not work with $context global....
(SMF 1.1.9 / SP 2.3)
-
Try:
if ($context['user']['is_admin'])
instead of
if ($context['allow_admin'])
When you want make things visible to different groups, you can try:
$allowed_groups = array(1, 2, 3, 4, whatever group should have access);
$can_see = FALSE;
foreach ($allowed_groups as $allowed)
if (in_array($allowed, $user_info['groups']))
{
$can_see = TRUE;
break;
}
if ($can_see)
{
echo '
Put your contend here
';
}
else
{
//message or section to show if they are not allowed.
echo '
default message if necessary
';
}
-
Nothing happens...
I am still Guest - even if i am loged on as Admin :(
very sad
-
You haven't included any of the SMF variables that you want to access, add this code to the start of the block.
global $user_info, $context;
-
Thanks a lot. Everything is workining. Thanks a lot!
Max