Hi ,
I’ve tried a lot of solutions about this topic but none of them worked in my case.I use PhpMaker V 2017.I wish my users to be redirected to a specific page according to their userleveid.here is my code in Server Events > Default >Login_page >User_LoggedInif (CurrentUserLevelid == -1) {
$url = “Admin.html”;
} else {
$url = “userpage.html”;
}
}Thanks for your help
There is no $url context in “User_LoggedIn” server event. You should use “Page_Redirecting” server event under “Server Events” → “Other Page” → “Default Page” instead.
Thanks for your help, but page redirecting does’nt still work.This is my last code In Other > Default Page > page_redirectingif (IsLoggedIn()) {
if (CurrentUserlevel() == ‘Administrator’) {
$url= “t_eqadd.php”;
} else {
$url = “t_eqlist.php”;Your help woudl free me !!!
Double check your code. It seems you missed two closing curly brackets.
Your code should be:if (IsLoggedIn()) {
if (CurrentUserlevel() == ‘Administrator’) {
$url= “t_eqadd.php”;
} else {
$url = “t_eqlist.php”;
} // <— end of else
} // <— end of IsLoggedIn
Thanks for your help.
But rather than in default page, for users of v 2017, you have to put the code in Page_Redirecting Server Event of the login page.
It works good.
Hi,
so I am on 2018 and tried this in Default Page :
// Page Redirecting event
function Page_Redirecting(&$url) {
// Example:
//$url = "your URL";
if (IsLoggedIn()) {
if (CurrentUserlevel() == 'Fussball') {
$url= "mitglieder_fussballlist.php";
} elseif (CurrentUserlevel() == 'Futsal') {
$url= "futsal_mitgliederlist.php";
} else {
$url = "mitgliederadd.php";
} // <--- end of else
} // <--- end of IsLoggedIn
} // <--- end of Page_Redirecting
For some reason it allways gives the “mitgliederadd.php” as default page for all Userlevelswhat I am doin wrong ?THX
CurrentUserLevel() should return an Integer, and not String. Make sure the field type of your “UserLevel” in your “users” table is Integer, then synchronize your project, and change your code above.
THX this works :
// Page Redirecting event
function Page_Redirecting(&$url) {
// Example:
//$url = “your URL”;
if (IsLoggedIn()) {
if (CurrentUserlevel() == 100) {
$url= “mitglieder_fussballlist.php”;
} elseif (CurrentUserlevel() == 112) {
$url= “futsal_mitgliederlist.php”;
} elseif (CurrentUserlevel() == 104) {
$url= “mitglieder_badmintonlist.php”;
} else {
$url = “mitgliederadd.php”;
} // <— end of else
} // <— end of IsLoggedIn
} // <— end of Page_Redirecting
The redirection based on Userlevel seems to work fine based on posts by @dh1340 and @mobhar using v2022.12.2 , but what I’m not clear on is how the Home breadcrumb can link back to that dashboard for the session.
I’ve got users going to the right dash on login but no way to get them back and the Home breadcrumb (or Home Link on navbar) makes the most sense.Any advice on how to accomplish this would be greatly appreciated - sorry for bumping an old thread.
ampsys56 wrote:
but what I’m not clear on is how the Home breadcrumb can link back to that dashboard for the session.
This was happened, since you define the Dashboard as your default page. This will cause the Home breadcrumb link will redirect to that Dashboard page. Please correct me if I’m wrong.
Yes, you’re right. I was overthinking it.I just needed to delete the declaration page on the ‘Generate’ Tab…leave it blank, let the code do the work.Its funny - I was about ready to add a ‘dashboard’ column to userlevels… In the end this was all I had to do.Thanks for your help.