View Single Post
  #1  
Old 04-10-2021, 01:28 PM
Micolai's Avatar
Micolai Micolai is offline
Loving Mysidia!
 
Join Date: May 2020
Location: Tennessee
Posts: 130
Gender: Female
Credits: 26,748
Micolai is on a distinguished road
Arrow Redirect based on group type

So I had wanted to be able to redirect people from my index page if they were logged in, that way it was only accessible by visitors. So I got this to work and wanted to share it.

In indexview.php put this:
Quote:
$group = $mysidia->db->select("users", array("usergroup"), "username ='{$mysidia->user->username}'")->fetchColumn();
switch($group){

case 1; //admin

$document->add(new Comment("<meta http-equiv='refresh' content='0; URL=http://www.dinotracks.mysidiahost.com/account' />"));

case 2; //deluxe

$document->add(new Comment("<meta http-equiv='refresh' content='0; URL=http://www.dinotracks.mysidiahost.com/account' />"));

break;

case 3; //member

$document->add(new Comment("<meta http-equiv='refresh' content='0; URL=http://www.dinotracks.mysidiahost.com/account' />"));
break;

case 4; //beta tester

$document->add(new Comment("<meta http-equiv='refresh' content='0; URL=http://www.dinotracks.mysidiahost.com/account' />"));

break;

case 5; //moderator

$document->add(new Comment("<meta http-equiv='refresh' content='0; URL=http://www.dinotracks.mysidiahost.com/account' />"));

break;

case 6; //visitor



break;

}
right under $document->setTitle("Dino Tracks"); that's in the public function index area.

This looks at the viewer's current group and says if they are anything other than visitor, they get redirected. So this can be used in many other areas too.
__________________
"You try you fail, you try you fail, but the only true failure is if you stop trying. So try again." - Haunted Mansion
Reply With Quote