Redirect after login for specific role on specific day using Rule

by latikas   Last Updated June 27, 2015 13:03 PM

I want to create a rule for specific user to redirect to his profile page on specific day like Monday and Thursday. For this, I used the Rules module, together with the Rules Once per Day module. If you're not familiar with this last module (which is pretty new), here are some quotes from its project page:

... to easily enable Rules to be fired once per day at, or soon after, a specific hour.

The module also provides a "Day of the week is a" Rules condition, to further restrict actions to being run on specific day(s) of the week, on working days only, or at weekends only.

But that didn't work so far.

I have also tried with PHP code, but that's not working either.

Answers 2

There is an interesting comment in issue 2495775, related to the "Rules Once per Day" module, from the module owner. It says:

You specify a trigger hour on the administration settings page for this module. The Rule trigger will then run when cron tasks are first run after the start of that hour. The actual run time will depend on your cron task timings.

The way I understand/Read this (haven't experimented with it yet though) is like so:

  • The "Event" will only be triggered when a cron job is run.
  • And that event will only be triggered 1 time / day, i.e. "next time cron runs after the trigger hour has passed".

Obviously, by using the "Day of the week is a"-option, an extra condition might be that the day has to match also.

With that in mind, it appears to me that this module can not help you to implement what you're trying to do. You want something to happen "when some user performs login", not "when some cron job is run".

But, maybe there is a way to reach your goal by cutting your problem / question in 2 parts:

  1. Create a 1st rule that takes care of "Redirect after login for specific role to "some URL".

  2. Create a 2nd rule that, using the "Rules Once per Day" module, sets the path for that "some URL". To actually set the path, their might be multiple options / modules to consider. I'm think of things like 'global redirect', using some 'token', maybe using the Variable module, etc (more investigation / research needed to find the best fit).

Yes the Rules module is one of those amazing Drupal modules. However it does have some challenges with processing dates ... (= open issues in its issue queue).

If the above doesn't help, then consider using an approach as detailed in the (great) answer to the question about Rule to check if a date value is a specific day of the week ...

Curious to hear if you can get it to work somehow.

June 06, 2015 09:30 AM

I got success to reach my goal by using "Rules Once per Day" module

I created only one rule that take care of "Redirect after login for specific role to "some URL" and for that i set, 'day of the week' and specific user role in condition. See following screen shot.

enter image description here

June 27, 2015 07:39 AM

Related Questions

Send Mail After Checking Date Field Value

Updated June 10, 2015 03:03 AM

Schedule unpublished nodes 3 times a day

Updated May 26, 2015 22:03 PM