EddyR
EddyR

Reputation: 6941

Redirect modules

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." message?

Upvotes: 1

Views: 1928

Answers (3)

Grayside
Grayside

Reputation: 4194

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.

Upvotes: 0

Scott Evernden
Scott Evernden

Reputation: 39966

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

Upvotes: 0

Reed Richards
Reed Richards

Reputation: 4378

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

http://api.drupal.org/api/function/drupal_goto

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.

Upvotes: 1

Related Questions