-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature request] Create a template variable to access SubscribeResponse #116
Comments
I have used this plugin inside a Sprig component and I has some problems because after a successful subscription, the mailchimpSubscribe was not accessible. A template variable would be a great addition! |
hi, any chance this works with sprig already? |
Got to the bottom of this (re sprig) but would need a plugin update to resolve I think. This means in essence it can never complete because the response is being treated as a I imagine that this needs to be set to following or similar:
@bencroker do you know if this is a problem that can be fixed at the Sprig level? |
@cole007 Why can't the redirect parameter be set to a blank string? |
i have done but for some reason it is still being passed through (or at least interpreted) as a hashed string by the time it hits the plugin controller. |
Get to the bottom of that and you should be able to solve it! |
Mailchimp Subscribe does not redirect if the posted redirect param is an empty string. |
This is why I am confused as to where the redirect variable is coming from (when sent via Sprig) - if there is no redirect specified or a redirect of So for example in my sprig form I have added the following parameter:
Then if in the plugin controller I insert the following:
The following is returned:
Even though if I inspect the XHR submission the value for redirect is empty. Not sure if this is happening at a sprig level or a Craft level or in this plugin 🤷♂️ |
Looks like this issue was already raised on putyourlightson/craft-sprig-core: https://github.com/putyourlightson/craft-sprig-core/issues/5 Relevant code here: https://github.com/putyourlightson/craft-sprig-core/blob/0af3e30d726e60c97a722255ce66b3ac98abab24/src/controllers/ComponentsController.php#L83 |
Thanks @aelvan, so we're back to square one, that the plugin should ideally return the result as part of the redirect, as is the convention with Craft controllers. return $this->redirectToPostedUrl(['mailchimpSubscribe' => $result]); |
@bencroker Hm, I don't think that would do anything. An I guess a quick fix on MailChimp Subscribe's end could be to make sure that the |
I think you're right @aelvan! What even is the issue @cole007? Is this check provided in https://github.com/putyourlightson/craft-sprig-core/issues/5#issuecomment-1012157446 not sufficient? {% if success is defined and success %}
Subscribed successfully!
{% else %}
Do something with the `mailchimpSubscribe` variable.
{% endif %} |
Thanks - that partly seems to work (sorry, was expecting these to be accessible via the One oddity though on testing is that This should be enough to get me going though, thanks both. even if I hit an error the response is showing as successful. |
Yes, given how the plugin controller works, that is the expected behaviour. |
There are times when the
mailchimpSubscribe
global variable is not accessible, or contains incorrect values (eg. when caching the page). In those cases, it would be great to have an easily accessible template variable to check the correct response status inside a nocache block (can be called something likecraft.mailchimpSubscribe.subscribeResponse
).The text was updated successfully, but these errors were encountered: