The need for this task is coming when combining Global Redirect, Boost and Mailchimp module together without setting a Thank You page for mailchimp signup form to redirect to. This is actually a Drupal core's bug but due to the fact that we are in the D8 era, I believe D7 won't be fixed for this minor issue. I may be wrong though. In the meantime we could fix the problem for Mailchimp only.
Drupal's drupal_redirect_form() invokes drupal_goto() for the current_path() if a $form_state['redirect'] is not set. This works fine in most cases. but for a block form this may not play well.
When the anonymous user submits the form, a POST request is made to the server. Boost's cache is ignored and the form gets submitted successfully. Since mailchimp is not configured to redirect to a specific page, drupal redirects to the original path of the frontpage (eg. /node). Then Global Redirect redirects properly to "/". Due to Boost's cache though, the message that "An email has been sent to you..." doesn't appear.
This whole problem may be fixed using two different methods:
- by explicitly setting $form_state['redirect'] to '' for the frontpage but to current_path() for any other page
- by settings $form_state['no_redirect'] to TRUE
Comment | File | Size | Author |
---|---|---|---|
#3 | proper_redirect_form_submit_to_frontpage-2915545-2.patch | 530 bytes | vensires |
#2 | proper_redirect_form_submit_to_frontpage-2915545-1.patch | 567 bytes | vensires |
Comments
Comment #2
vensires CreditAttribution: vensires commentedThis patch explicitly sets $form_state['redirect'] to '' for the frontpage but to current_path() for any other page
Comment #3
vensires CreditAttribution: vensires commentedThis patch explicitly sets $form_state['no_redirect'] to TRUE
Comment #4
vensires CreditAttribution: vensires commented