I've created a basic page with url login.

The node id is 129 and I've made a custom page--node--129.tpl.php in my theme. On that file I've put this:

<?php print $messages; ?>
<div class="admin-login">
<?php print drupal_render(drupal_get_form('user_login')); ?>

So on this page I'm rendering the user_login form and I'm using it as a page for admin login. How can I set redirect when admin is logging, lets say to admin/content?

  • You can use rules module to redirect user based on role.
    – Anil Sagar
    Jan 27, 2014 at 9:51

2 Answers 2


Implement hook_user_login():

function MY_MODULE_user_login(&$edit, $account) {
  if(/* CONDITION, e.g.: $account->uid == 1 */) {
    $edit['redirect'] = 'admin/content';
  • I've used a Rules module, but your answer is useful too, so I'm giving you +1. Thanks. Jan 27, 2014 at 9:53

I've managed to solve this by using Rules module and here's the process, so maybe will help someone.

Create a new rule.

Events: User has logged in.

Condition: User has role

Actions: Page redirect

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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