Drupal: How To Redirect Users To Front Page Based On Different User Role?

Drupal How To Set Different Front Page or Home Page For User Based on Different User Role  Drupal: How To Redirect Users to Front Page Based on Different User Role?

There may be times when we may want to direct users based on their Drupal Roles to different Front Page. For instance, we want users with direktur and content admin roles to see a dashboard, and regular users with "Authenticated User" roles to another dashboard specially designed for those users. In such cases, we want to redirect users based on their roles to different dashboard.

In this post, we shall see how to set different Front Page for users based on their user roles. Page redirection can be easily achieved by using Rules. If you don't want to do it with rules, there are modules available for setting front page for different user roles. We shall be check out two methods to set front page for different user roles - by using Rules Module and another by using "Front Page Module" from Drupal Projects.

METHOD ONE:
Setting different front page in Drupal for different user role using Rules Module
This is an example how to set  different front page in Drupal for different user role using Rules Module based on Drupal 7. If your don't have the Rules module installed already, get it here (Drupal Rules Module). There are three basic things in setting up Rules - Events, Conditions and Actions. We'll see them for this context.
Drupal How To Set Different Front Page or Home Page For User Based on Different User Role  Drupal: How To Redirect Users to Front Page Based on Different User Role?
Drupal Rules - Event, Conditions, Actions

Steps for creating rule for setting a different Front Page for a user role:
  • Login to Drupal as an Administrator
  • Go to Configuration > Workflows > Rules
  • Add a new rule and name the rule
  • React on event = "User has logged in"
  • Save it
  • Conditions
    • Conditions > Add a condition
    • Condition = User has role(s)
Drupal How To Set Different Front Page or Home Page For User Based on Different User Role  Drupal: How To Redirect Users to Front Page Based on Different User Role?
Drupal Rules - Condition - User Has Roles
    • Select the required roles. Press and hold CTRL key to select multiple roles
    • Match Roles = All or Any. Select ANY if you have selected multiple roles and you want Drupal to check any of the selected roles. If ALL is selected here, Drupal will check if the logged in user has all the roles selected before applying the rule. 
    • Negate: If you want to negate any of the selected roles, that is, to apply the rule not on the selected roles, check it. Otherwise, leave it as it is.
    • Save
  • Actions
    •  Add Action
    • Select the action to add = select "Page Redirect" under System
    Drupal Rules - Actions - Page redirect

    • Enter the URL value (Eg: for the path www.example.com/dashboard, enter only "dashboard" without the quote.)
    • Check Force Redirect = True
  • The Rule page looks like this.
In this rule, we have defined to check if the logged in user has the roles we selected and if yes, redirect the user to the the URL defined.

Drupal Rules - Event, Condition and Actions for Page Redirect based on User Role

  • Save Changes
  • Try logging in with a user role we selected in the rules and test.

When a user with the User Roles defined logs in, Drupal should redirect the user to the URL we define in the rules.

METHOD TWO:
Setting different front page in Drupal for different user role using a "Front Page" module
If you don't like to create rules for this, you can download and install the "Front Page" module from 
https://www.drupal.org/project/front

I am not covering how to install the module and use it here. You can install the module like we install any other Drupal Module and check its configuration page to change behavior of each role in your Drupal system.

I hope this post helps someone in setting up rules for redirecting to a different Front Page in Drupal.
 If this post was of help or if there are any queries specific to this post, kindly like, share and comment. 
     

Sumber http://techubber.blogspot.com/

0 Response to "Drupal: How To Redirect Users To Front Page Based On Different User Role?"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel