PDA

View Full Version : User Re-Direct to NO PERMISSIONS


MacroPhotoPro
04-10-2015, 04:52 PM
Have the following code to specify which users can use a custom page of mine:

// Permissions Redirect
if ($usergroupid==8) {
header("Location: $url_/payments.php");
} else if ( ($usergroupid != 5) && ($usergroupid != 6) && ($usergroupid != 7) && ($usergroupid != 9) && ($usergroupid != 10) && ($usergroupid != 11) ) {
header("Location: $url_/payments.php");
}

This directs people to the payments.php page, but I have one "Administrative Only" page, where I don't want to direct them to payments.php, but where I want to elicit a No Permission message, so how do I code the above to accomplish this?

Thanks!!

kh99
04-10-2015, 05:24 PM
You can call the function print_no_permission(), no parameters, like:
print_no_permission();

MacroPhotoPro
04-10-2015, 05:34 PM
Okay so, code it like:

// Permissions Redirect
if ($usergroupid==8) {
header("print_no_permission");
} else if ( ($usergroupid != 5) && ($usergroupid != 6) ) {
header("print_no_permission()");
}

Or do I do something different?

Thank you again for your help.

kh99
04-10-2015, 05:39 PM
Well, more like this:
// Permissions Redirect
if ($usergroupid==8) {
print_no_permission();
} else if ( ($usergroupid != 5) && ($usergroupid != 6) ) {
print_no_permission();
}

Also, I just remembered that there's a function called exec_header_redirect() that takes the url as a parameter, which you might want to use for your other redirects since it ends the script instead of going on and generating the rest of the page. To use that you'd replace
header("Location: $url_/payments.php");

with
exec_header_redirect("$url_/payments.php");

MacroPhotoPro
04-10-2015, 05:58 PM
Awesome, that did the trick, thank you :D

--------------- Added 1428695984 at 1428695984 ---------------

Much appreciated!!