0

I have created a custom form for login page. When a user logs in, I want to redirect the user to some other page, different from user/<user_name>.

How can I perform such redirect?

0

2 Answers 2

2

You can use the Rules module.

Example use cases

Build flexible content publishing workflows changes Send customized mails to notify your users about important Create custom redirections, system messages, breadcrumbs, ... And many more...

To use that go to admin/config/workflow/rules/reaction/import and import this it will redirect user to admin/dashboard path after user logged in :

{ "rules_redirect_after_login" : {
    "LABEL" : "redirect after login",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "user_login" : [] },
    "DO" : [ { "redirect" : { "url" : "admin\/dashboard" } } ]
  }
}

You may also build a custom module and use hook_user_login and do something on the lines of :

function hook_user_login(&$edit, $account) {
     $_GET['destination'] = 'node/25';
 }
1

You and also use the Login Destination module and in the config set the redirect.

The Login Destination module allows you to customize the destination that a user is redirected to after logging in, registering to the site (7.x), using a one-time login link or logging out (7.x). The destination can be an internal page or an external URL. It is possible to specify certain conditions like referring pages or user roles and make the destination depend upon them. You may use PHP snippets to provide custom conditions and destinations. It is also possible to keep users on the currently visited page after logging in or out.

Not the answer you're looking for? Browse other questions tagged or ask your own question.