Hello first of all thank you for this script is saving me lots of time, I hope you can help me with an issue I face, I have setup a different login redirection in custom_login_script.php this has been set to ../../access10/main.php I have some apps that live in access10 and some are available for all users and some are not however I have chosen for design reasons to show the links to all users.
I have access10/main.php and access10/advanced.php showing buttons to other functions all in differnet pages, when I am in main.php and click a function with a user who does not have permissions it does nothing just seems to refresh the page, however in when I do the same in access/advanced.php it goes back to access/main.php I have searched the code and even tho I have included some conditionals in custom_login_script.php and in other places I happen not to understand the code fully yet, could you please point me in the right direction?
Again, thank you very much for this app and your help.
Regards
Carlos
As always, after you post you find out there is somethig else going on, in the root directory index.php file I have added this code
if($user->isLoggedIn()){
Redirect::to('../../access10/main.php');
}
which sends the user to the main page if the user is logged otherwise displays the login screen.
So it seems the code is sending me back to index.php, where can one add some logic to dinamically change the redirection when a user is trying to access a page the user has no permission to see? or better yet is there a way to show an error in the page to inform the user he does not have access to that page? your help is much appreciated,
Happy new Year
Carlos
The more people use userspice, the more people want these kinds of custom scripts in that situation. I'm going to work on something for that. But, you're on the right track that you can totally do your logic on index.php. I have a few ideas I'm going to tinker with.
Happy New Year! Thanks for the feedback.
I think the trick is going to be that at the bottom of the securePage function over in us_helpers, there is a just a redirect to the homepage. What we need is to pull from another file over in usersc so people can put whatever code they want.
I'm not sure if you know this, Brandin, but any time you do a redirect, you can do a get request at the end and flash a message on the screen. I even do that as a quick way to give user feedback.
So, let's say you have someone complete a form and then want to send them back to a file called cpanel.php, you can do
Redirect::to('cpanel.php?err=Form+complete!+Thank+you+for+your+submission!');
And they will be redirected and have that message flash up on the screen.
OH. MY. GOSH. YOU JUST MADE MY LIFE COMPLETE. I am going to start implementing this. I think that would be the easiest solution! Just adding a message!
Yeah. I'm adding that as the default to tell people why they got redirected somewhere. One of the huge things is that if you are using php, you refresh the page on submit to make things open and if you redirect, you lose your errors, so this is a great combination. If on success, I redirect with a message and I don't have to refresh the page.
If you figure that out, let me know. I really want to make the err be a danger and msg be success on that. So if you do it with err now, it will be a danger automatically when you patch the redirect class as soon as I can roll that out.