Closed 1stevengrant closed 1 year ago
Have you double checked that the mailing list is enabled and that the mailing list type is enabled for the site you're testing with?
aha - that's what's thrown me...the relationship between a mailing list and site.
Here's my conundrum, we have multiple sites in this instance.
We have an organisation site and a site for a conference the organisation operates.
The mailing list was assigned to the organisation but being called on the conference site. Is there a way to do that?
Have you tried adding .siteId(1)
to the query, replacing 1
with the site ID the mailing list type is enabled for?
brill, thanks so much @bencroker - just the job
@bencroker another likely dumb question but with this snippet
<form method="post" action="">
{{ csrfInput() }}
<input type="hidden" name="action" value="campaign/forms/subscribe" />
<input type="hidden" name="mailingList" value="{{ mailingList.slug }}" />
<input type="hidden" name="redirect" value="{{ 'subscribe-success'|hash }}" />
when submitting the form I get the error Mailing list not found
in /vendor/putyourlightson/craft-campaign/src/controllers/FormsController.php
is that because it's trying to find a form with that particular slug in the context of the current site?
Yes, it looks like the same issue as above.
Yes, it looks like the same issue as above.
so that will never work the way I intend then doing
{% set mailingList = craft.campaign.mailingLists.siteId(4).id(49863).one() %}
<form method="post" action="">
{{ csrfInput() }}
<input type="hidden" name="action" value="campaign/forms/subscribe" />
<input type="hidden" name="mailingList" value="{{ mailingList.slug }}" />
<input type="hidden" name="redirect" value="{{ 'subscribe-success'|hash }}" />
...
Yeah I see what you mean. I may add an optional siteId
parameter to the forms controller. Are you running Campaign 2?
yeah, latest version. That would be useful. Appreciate this is probably quite edge case.
My workaround for now is to use a Freeform form to capture details and hook up their Campaign integration in the background.
I added an optional siteId
parameter to the front-end subscribe and unsubscribe forms in https://github.com/putyourlightson/craft-campaign/commit/5f068f268d3543621a16aa6b283c531476cf50d6 and released in version 2.5.3.
<input type="hidden" name="siteId" value="2" />
what a man! thank you
FYI I updated the docs at https://putyourlightson.com/plugins/campaign#front-end-forms
Kicking the tyres on Campaign for a project.
I've configured the plugin and in the control panel I can see mailing list, contacts but for some reason, when I query the mailing list based on id, as per the docs
the mailing list definitely exists, I've tried deleting it and recreating but still the same issue. I can see the mailing list in the database also.
I'm stumped. Any gotchas that I'm missing?
I've also tried getting by
handle
andslug
🤷♂️