Custom login redirect using the Rules Module

TAGS:

A client of ours recently had a perfectly reasonable request. They wanted their users to be redirected to a CiviCRM profile upon logging in so their users can update their contact information. But they only wanted this redirect to happen the very first time they login; not every time which would get annoying.

My first reaction to this was "oh no, custom code!" But I knew that the very powerful Rules module can let you create URL redirects based on conditions. So I started playing with the module but got stumped because there is no conditiion for checking to see if it is the user's "first login" or anything like that.

A quick google search found this post http://drupal.org/node/245209 that explains how to do exactly what I wanted! It's incredibly simple but so powerful. Here is the recipe in case it helps:

  1. When you create new users in Drupal, give them a temporary role called "newbies" or whatever you like and the normal role you would assign to them like member that they'll keep forever.
  2. Create a rule that takes place on the event: user has logged in.  
  3. The condition is that the user has the "newbie" role.
  4. The actions for the condition are as follows:
    1. Page Redirect. In our case, we redirect new users to a CiviCRM profile with the fields we wanted people to update.
    2. Remove User role. This is the cool one! This action removes their "newbie" role so this rule will never come in to play again for this user because the condition will never again be met.

Attached is an export of the rules.

Attachments: 

Comments

  • Showing 1-0 of 0

Post new comment

Image CAPTCHA
Enter the characters shown in the image.