Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Questions and Supports

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 04-08-2021, 06:04 PM
Micolai's Avatar
Micolai Micolai is offline
Loving Mysidia!
 
Join Date: May 2020
Location: Tennessee
Posts: 130
Gender: Female
Credits: 50,468
Micolai is on a distinguished road
Question Help with page redirects

Does anyone know how I go about making a page only viewable by visitors, so if you're already a member it just takes you to a specific page? I know how to do page redirects, but I need something that checks to see if you're a specific group.

Basically I'm wanting my members to not be able to go to the home page unless logged out. So only visitors can access the page.
__________________
"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
  #2  
Old 04-10-2021, 04:00 AM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 109,900
Kyttias is on a distinguished road
Default

You can use $mysidia->user->usergroup->gid to get the numerical value of the usergroup the current viewer has and block 'em out that way. Alternatively, $mysidia->user->usergroup should pull up a string version that is the name of the group. I can't remember off the top of my head what all the default usergroups are.
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it.
Reply With Quote
  #3  
Old 04-10-2021, 11:18 AM
Micolai's Avatar
Micolai Micolai is offline
Loving Mysidia!
 
Join Date: May 2020
Location: Tennessee
Posts: 130
Gender: Female
Credits: 50,468
Micolai is on a distinguished road
Default

Does all this need done in the login.php file or index.php file? I'm so confused lol. The visitor group I think is the guest group and it's all number 6.

Edit:

Oh my gosh!!! I got it! I had it in the wrong file! This is what I used:

$group = $mysidia->db->select("users", array("usergroup"), "gid ='{$mysidia->user->gid}'")->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;

}
__________________
"You try you fail, you try you fail, but the only true failure is if you stop trying. So try again." - Haunted Mansion

Last edited by Micolai; 04-10-2021 at 12:03 PM.
Reply With Quote
  #4  
Old 04-11-2021, 01:43 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 109,900
Kyttias is on a distinguished road
Default

So you know, you don't have to make a query for that information, its in the variable $mysidia->user->usergroup->gid, which exists in exactly the same way $mysidia->user->gid did in your query..

PHP Code:
$redirect "";
switch (
$mysidia->user->usergroup->gid){
  case 
1$redirect"yes"; break;
  case 
2$redirect"yes"; break;
  case 
3$redirect"yes"; break;
  case 
4$redirect "yes"; break;
  case 
5$redirect"yes"; break;
  default; 
$redirect "no";
}
if (
$redirect == "yes"){
  
$document->add(new Comment("<meta http-equiv='refresh' content='0; URL=http://www.dinotracks.mysidiahost.com/account' />"));

Which works great if you want to, in the future, redirect to different areas for the different groups, I guess...? But if you're only wanting different behavior for one of them... You could literally just do this in one if statement (if user group id does not equal 6, then redirect).

PHP Code:
if ($mysidia->user->usergroup->gid !== 6){
  
$document->add(new Comment("<meta http-equiv='refresh' content='0; URL=http://www.dinotracks.mysidiahost.com/account' />"));

I'm not sure if you could get away with a php header redirect with Mysidia's messiness, but I don't think have things up and running to test it out - so if your html redirect is good enough for your purposes, great!
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it.

Last edited by Kyttias; 04-11-2021 at 01:50 PM.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 06:13 AM.

Currently Active Users: 805 (0 members and 805 guests)
Threads: 4,081, Posts: 32,029, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636