Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

Role dependant content?

edited November 2008 in Vanilla 1.0 Help
Is it possible to create a role-dependant content? Lets say I've created a page using Page Manager and want users with different roles see different content. Can it be done using PHP (Page Manager allows PHP)?

Comments

  • Options
    Now there's a good idea - let us know if anyone comes up with anything!
  • Options
    yes you can write php in page manager pages. e.g.<p>Hello <?php echo $this->Context->Session->User->Name; ?> !</p>
  • Options
    @miquel: That actually isn't the answer to my question; I already know that I can use PHP in Page Manager, but thank you for your input.

    What if statement should I use to determine a user's role?
  • Options
    <?php switch($this->Context->Session->User->RoleID) { case 4: // Administrator code case 3: // Member code case 2: // Banned code case 1: // Unauthenticated code }
  • Options
    edited November 2008
    <?php if ($this->Context->Session->UserID == 0) { $URL="http://path.to/forum/?Page=Guest"; header ("Location: $URL"); } ?>

    This is what I use to re-direct non-members to a Page Manager page (called Guest) I want guests to see.

    I hope it helps.

    Later... Here it is in an if-else statement...

    <?php if ($this->Context->Session->UserID > 0) { $URL="http://path.to/forum/?Page=Member"; header ("Location: $URL"); } else { $URL="http://path.to/forum/?Page=Guest"; header ("Location: $URL"); } ?>
This discussion has been closed.