0

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')); ?>
</div>

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 '14 at 9:51
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. – user2519032 Jan 27 '14 at 9:53
0

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, privacy policy and cookie policy

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