I created a simple rule where:
Event: User has logged in.
Action: Page Redirect to [site:url] (I have tested several other urls)..

I have also tested the event itself by adding an action to send an e-mail, and it worked.

CommentFileSizeAuthor
#5 rules-190124.patch1.66 KBpivica

Comments

fago’s picture

Component: Rules Core » Rules Engine
Status: Active » Fixed

thanks, indeed there was a @todo in the code to fix that. So I fixed it.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

RumpledElf’s picture

I'm using the alpha 3 version and just had a hair tearing out moment that rules simply did NOT work and I must be doing something wrong until I found this issue.

It still doesn't work.

RumpledElf’s picture

Status: Closed (fixed) » Active
pivica’s picture

Version: 7.x-2.0-alpha1 » 7.x-2.x-dev
Status: Active » Needs review
StatusFileSize
new1.66 KB

I have a same problem, the only difference is that I am using 'After saving new content' event and I want to redirect user to some other page when it submit new content.

Problem is that rules redirection rule is using $GLOBALS to store redirect url, which is OK in most situations, but not for form submit events - most of the times Drupal forms will do it own redirection after form submission (before rules can interfere) and on that next redirected page rules will check should it redirect again but $GLOBALS will also be recreated now so $GLOBALS['_rules_action_drupal_goto_do'] is lost.

Easy solution is to use $_SESSION instead of $GLOBALS like in attached patch.

pivica’s picture

Unfortinatly #5 is not working for the next case

- Anyonimus user has a right to create a node that is going to moderation (not published) - he can create but can not view this node upon creation.
- On node save everything is going ok until we come to rules_page_build, there drupal_goto($url) will be called with correct $url but then in drupal_goto execution it will be overridden with $_GET['destination'] which somehow magically is set to path of a newly created node.

For now I just did

if (isset($_SESSION['_rules_action_drupal_goto_do'])) {
    // $_REQUEST['destination'] has been set, drupal_goto() will use that.
    $url = $_SESSION['_rules_action_drupal_goto_do'];
    unset($_SESSION['_rules_action_drupal_goto_do']);
    unset($_GET['destination']); // ugly hack
    drupal_goto($url);
  }

Ugly, but I need this to work fast and don't have time to investigate more. If I found some other solution later I will post it here.

jyee’s picture

I'm using alpha 4 and the redirect is still not working. Like the original post, i've tested with a few other actions and they work, just not the redirect.

change from $GLOBALS to $_SESSION as mentioned in #5 worked for me.

Weaver’s picture

Hi all, please see me post at http://drupal.org/node/1024306

I have included very simple instructions to be able to re-create the problem, so hopefully someone with better programming skills than I will be able to address it soon.

pivica's solution seems perfectly logical, lets hope fago can get some time on this one soon as its bugging the hell out of me! :-)

likewhoa’s picture

patch in #5 fixes this for me also.

fago’s picture

Status: Needs review » Fixed

Using the SESSION is unnecessary complicated and just works around the problem letting the redirect not work in the first place. Anyway, I take a look at it and fixed the problem. See http://drupal.org/node/1024306#comment-4070132.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.