0
votes

I have a Drupal site which has two pages A(www.mysite.com/A) and (www.mysite.com/B). I want to create a module which will do the following things

-When a user accesses page A detect it.

-Performs some checks in db to find out whether user has access to A

-If user does not have access to page A then redirect him to page B

-Load page B

I am not able to find out which hooks let me alter the path before page loads. Please Help .

1
Thanks !! I will try itAkshay Barge

1 Answers

1
votes

If you are the author of the route A, you can do this in the 'access callback' of you hook_menu() using drupal_goto(), else if you are trying to modify the behavior of another module, you can do this in a hook_menu_alter().

Another option (not pretty), is to implement a hook_init() like this:

function yourmodule_init() {
  if (current_path() == 'A') {
    // Do some DB checks...
    drupal_goto('B');
  }
}