Different Roles for 2 different type user in Drupal
I have to 2 different roles setuped in drupal.
1) Backend Users 2) Authenticate Users
Backend Users I want backend users to be redirected to admin section (were all admin related work is done)
Authenticate Users Authenticate users to be redirected to front pag开发者_如何学Goe.
What is best way to achieve this.
You have more than one choice.
There are several contrib modules that can achieve this functionality. On one of my production sites I use with satisfaction login destination, as it allows to include PHP logic to decide where to redirect the user.
If you are already writing some code, though, you could to implement this behavior programmatically (this is surely lighter on the system than a fully-featured module), by implementing hook_user()
and defining a case for $op == 'login'
: you could then use drupal_goto()
to give the address of the page you want the user to be redirected according to her/his roles.
HTH!
Try the 'LoginToboggan' module. It is a module that has that functionality built in. Some details about it (from its project page):
The LoginToboggan module offers several modifications of the Drupal login system in an external module by offering the following features and usability improvements:
- Allow users to login using either their username OR their e-mail address.
- Allow users to login immediately.
- Provide a login form on Access Denied pages for non-logged-in (anonymous) users.
- The module provides two login block options: One uses JavaScript to display the form within the block immediately upon clicking "log in". The other brings the user to a separate page, but returns the user to their original page upon login.
- Customize the registration form with two e-mail fields to ensure accuracy.
- Optionally redirect the user to a specific page when using the 'immediate login' feature.
- Optionally redirect the user to a specific page upon validation of their e-mail address.
- Optionally display a user message indicating a successful login.
- Optionally combine both the login and registration form on one page.
- Optionally have unvalidated users purged from the system at a pre-defined interval (please read the CAVEATS section of INSTALL.txt for important information on configuring this feature!).
- Integrates with Rules module to do various tasks when a user validates via email validation process (see http://drupal.org/node/880904 for an example)
精彩评论