SimplePortal

Customization => Custom Coding => Topic started by: efimomax on September 06, 2009, 07:27:04 AM

Title: Need help with custom PHP page
Post 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):
Code: [Select]
<?php ssi_welcome(); ?>
but this is don't work :( Always show that i am not admin  (do not metter admin i am or not)....
Code: [Select]
<?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)
Title: Re: Need help with custom PHP page
Post by: ianus on September 09, 2009, 01:17:46 AM
Try:
Code: [Select]
if ($context['user']['is_admin'])instead of
Quote
if ($context['allow_admin'])


When you want make things visible to different groups, you can try:
Code: [Select]
      $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
';
      }
Title: Re: Need help with custom PHP page
Post by: efimomax on September 12, 2009, 10:59:59 AM
Nothing happens...

I am still Guest - even if i am loged on as Admin :(

very sad
Title: Re: Need help with custom PHP page
Post by: Nathaniel on September 12, 2009, 07:30:37 PM
You haven't included any of the SMF variables that you want to access, add this code to the start of the block.

Code: [Select]
global $user_info, $context;
Title: Re: Need help with custom PHP page
Post by: efimomax on September 14, 2009, 02:11:09 AM
Thanks a lot. Everything is workining. Thanks a lot!

Max
SimplePortal 2.3.8 © 2008-2024, SimplePortal