Hi folks,

When logging out I am dumped at the home page, I want to redirect to another page. Tried appending the logout menu entry with ?destination=user but that makes no difference. Any ideas?

Thanks in advance.

Comments

cmak’s picture

You need to implement hook_user in your custom module like this

<?php
function hook_user($op, &$edit, &$account, $category = NULL) {
  //check if the user is just logged out
  if ($op == 'logout') {
      //redirect user to other path than that of homepage
     drupal_goto('path');
  }
}
?>

Senior Drupal Developer
Skype me on : mak_chavan
Email : Makarand Chavan

ludo1960’s picture

Many thanks for you reply, would of thought there was an easier way than creating a module for such a simple task.

cmak’s picture

appending a ?destination=your_path need to help.
e.g <a href="/drup6/?q=logout&destination=node/2">Log out</a>
worked for me.

Senior Drupal Developer
Skype me on : mak_chavan
Email : Makarand Chavan

niyas’s picture

You could do this using RULES module since we can define actions that should be triggered when the corresponding event occurs.

ludo1960’s picture

Tried creating an action Redirect to URL then when I went to trigger that action i get "Trigger: After a user has logged out No available actions for this trigger." Why so difficult?

niyas’s picture

Have you enabled rules module http://drupal.org/project/rules ? Once you enabled you will see the rules settings under configuration to create rule with 'event'(there you can see the option "when user logged out") and 'action' (there you can see the option "Redirect to URL").

ludo1960’s picture

Perfect, thank you very much. A simple case of can't see the wood for the trees! A common drupalist complaint I believe!