Redirect to homepage if access to an extension is denied

Author Message

Carlos Revillo

Tuesday 05 June 2007 12:34:00 pm

Hello. Now i wanna make an extension. Let's call it "articles".
I have two kind of users. Group Users can be A or B.

B users have access to "articles", but a Users A haven't.

So, if an A user tries to work with articles extension, he is showed an error message.

I don't want to show this message to A user. Instead of, i want redirect him to my homepage, so he can login from there.

I know i can play with ezUser::hasAccessTo("module") or something like that... but where do i have to do this check? Will it be sufficient if i do it in my module.php file, or should i do for all the views of my extension?

Thank you.

Bruce Morrison

Tuesday 05 June 2007 4:27:31 pm

Hi Carlos

Permissions are handled before the module views are run, so to do what you are asking you'd have allow all users to access the view(s) and redirect dependant on the user.

If you were willing to redirect all "access denied" access to the homepage you can setup this behaviour in error.ini. Doesn't appear to be documentated but the comments in the main ini file should give enough info for you to get by.

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Carlos Revillo

Wednesday 06 June 2007 3:12:56 am

hi. thanks a lot. it worked.

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.