Page 1 of 1

Conditional global redirect

Posted: Tue May 23, 2023 10:42 pm
by Satrapo

Hi, maybe it's a stupid question however I cannot figure how to do this.

PhpMaker 2023

My tables are: user, orders, item, service

In user table there is: "has_read_the_doc" field.
Well if this field is set to false from every page of the site (list,view,edit etc etc) the user has to be redirected to his specific userView page.

This code works but I nedd to put it in every Page Redirecting event

    if(!CurrentUserInfo("has_read_the_doc")){
    $theUrl = CurrentUserInfo("id");
    $url = "UserView/$theUrl?showdetail=";
    }

There is a way to obtain the same result without putting this code in every Page Redirecting event?

Thanks!


Re: Conditional global redirect

Posted: Wed May 24, 2023 7:39 am
by arbei

If you are not using modal pages, you may try Page_Unload server event, e.g.

// ... your code to set $url
Redirect(GetUrl($url)); // Redirect

Re: Conditional global redirect

Posted: Thu May 25, 2023 5:39 pm
by Satrapo

Thanks, it works.