tags:

views:

464

answers:

3

How can I get a Module to redirect if a user doesn't have the correct permissions to view it instead of getting the usual "Access denied. You are not authorized to access this page." page message?

+1  A: 

If it is a module you are writing yourself use the goto function of Drupal

http://api.drupal.org/api/function/drupal%5Fgoto

If you are not writing it yourself then it's a bit tougher, you can set the error redirects with Drupal and some modules however for a specific module I think you might have to go in and patch it in some way.

Reed Richards
A: 

pretty much anything you wanna do to modify drupal stock behaviour can be handled via hook_nodeapi

Scott Evernden
A: 

Custom Error provides the ability to easily customize 403 and 404 error messages. With that, you could use drupal_goto() to automatically redirect users, or drupal_get_destination() to build a login link that will return the user to the page they attempted to view.

For more general, login-specific functionality, you might check out LoginToboggan.

The source code for both modules will also include useful examples of how to approach this problem space if you do not want the overhead or external dependency of a module.

Grayside

related questions