0

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.

  • I agree with Pierre - using Rules Once per day will do nothing. triggering after a user logs in is what you want. If you haven't overriden the default redirect behaviour you would only need one rule to trigger when the date doesn't match (since the default directs users to their profile), othrwise You could create two Rules, one that matches the date, and one that doesn't, each with its own redirect, or use Conditional Rules to keep it all together – Geoff Jun 6 '15 at 17:50
0

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

0

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.

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.