0

I'd like users registering on my website are redirected to the page where they clicked the "create account" button which is in a modal.

First, I tried to redirect to an absolute url I tried

$form_state->setRedirect($myUrl);

I tried

$_REQUEST['destination'] = '<front>';

I tried this too :

$response = new \Drupal\Core\Routing\TrustedRedirectResponse('http://www.google.be');
$form_state->setResponse($response);

I'm always redirected to /user/[uid]/edit

0

You could use Rules module to achieve that..

  • Does Rules module allow to go to the previous page ? – lbogdan Jun 15 '17 at 12:59
  • A page redirect can be done to "a drupal path, path alias or external URL" – dharma Jun 15 '17 at 13:25
  • @dharma true for D7, but I would really, really, repeat really, want to see an improved version of your answer that explains HOW to do this with Rules in D8 ... – Pierre.Vriens Jun 15 '17 at 14:51
0

You can accomplish this with the Rules Link module, and using the php variable php variables %server[HTTP_REFERER]

Or, without having to enable php in rules, you can use a custom 'previous page' token, explained in this drupal.org issue.

Create a rule that triggers when the link is clicked, stores the previous page a a variable, do some other actions you want and at the end a redirect action to that previous page variable.

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.