Skip to content
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: subscribing to multiple mailinglists in one form #19

Closed
phoob opened this issue Oct 2, 2018 · 16 comments
Closed

Feature request: subscribing to multiple mailinglists in one form #19

phoob opened this issue Oct 2, 2018 · 16 comments
Labels
enhancement New feature or request
Milestone

Comments

@phoob
Copy link
Contributor

phoob commented Oct 2, 2018

Hello!

We have a subscription form where we allow users to sign up to multiple mailinglists. We implement a logic that sends one request per mailinglist to the plugin. You can see the implementation here (in norwegian): https://dfo.no/kundesider/kundenotater/abonner-pa-kundenotater

The problem is, the user receives one verification email per list (both have double opt-in), and s/he have to click the links in both emails to get signed up. It would be nice if the plugin could have better support for these use cases.

@putyourlightson
Copy link
Collaborator

Thanks for the request. What would you suggest, a single opt-in email for multiple mailing list subscriptions?

@phoob
Copy link
Contributor Author

phoob commented Oct 2, 2018

Yes, that’s kind of what I had in mind, but I’m of course open to other suggestions as well. We thought about combining the mailing lists, and target subscribers based on their “interests”, as stated in a custom field. but then there would be no option for the user to edit their preferences later on. So I guess a separate feature request would be to have a possibility for the subscriber to get an overview of all his/her subscriptions (and custom fields).

@putyourlightson putyourlightson self-assigned this Oct 2, 2018
@putyourlightson putyourlightson added the enhancement New feature or request label Oct 2, 2018
@putyourlightson
Copy link
Collaborator

Ok, let me think about it, perhaps adding a contact edit form would be a good thing which would also solve your original request.

@phoob
Copy link
Contributor Author

phoob commented Oct 3, 2018

Ok, let me think about it, perhaps adding a contact edit form would be a good thing which would also solve your original request.

Sounds good! Would be nice to have a link to that form available in the campaign template :)

@phoob
Copy link
Contributor Author

phoob commented Oct 3, 2018

Oh, also: we had a problem with subscribe-actions (and possibly import actions) breaking/throwing errors when we had a tag field for contacts. Perhaps some logic could be made so that they are imported/exported by slug/id instead of the entire tag/category object..?

@putyourlightson
Copy link
Collaborator

Please create a new issue for the tag field with details of the error.

@phoob
Copy link
Contributor Author

phoob commented Oct 16, 2018

Hello again! Have you given the original issue any more thought?

@putyourlightson
Copy link
Collaborator

We have a big update in v1.4 coming out this week. Once that has shipped I'll be able to give this some more attention.

@putyourlightson
Copy link
Collaborator

I've given it some thought and trying to combine multiple verification emails into a single one doesn't seem feasible, considering that each mailing list can have its own verification email and success template. I'm more inclined to go for adding a contact update form, which will allow contacts to view and modify their email address and custom field values. Changing their mailing list subscriptions in the same form presents the similar issues with the double opt-in process as above though, so this may not make it in. Would this still be a viable solution for your use case?

@putyourlightson putyourlightson added this to the 1.5 milestone Oct 20, 2018
@putyourlightson
Copy link
Collaborator

Ok so I've added an anonymous update contact controller action which should allow you to create a form on the front-end so that contacts can change their details. You'll need to build the form yourself but the logic is in place, care to take a look? (this is in the develop branch)
d79e7f3

@phoob
Copy link
Contributor Author

phoob commented Nov 7, 2018

Trying it now! Sorry but what's with validating the contact->uid..? how do you expect the frontend to get the contact->uid?

@putyourlightson
Copy link
Collaborator

putyourlightson commented Nov 7, 2018

Sorry I didn't explain this earlier, but I've made the contact's UID required as a way to ensure that contacts (or anyone for that matter) can only update their details if you submit their UID along with their request. This is a security feature, since this is an anonymous controller action and no actual authorisation takes place.

You should include the following hidden input fields in the front-end form:

<input type="hidden" name="cid" value="{{ contact.cid }}" />
<input type="hidden" name="uid" value="{{ contact.uid }}" />

@phoob
Copy link
Contributor Author

phoob commented Nov 8, 2018

Hello again! Awesome, this works :) Now the only thing I'd really want to do is to allow the user to easily edit his/her subscriptions using the same form.. I can get the subscription status for each mailinglist doing something like this:

{% set contact = craft.campaign.contacts.cid('qwerty1234').one() %}
{% set mailingLists = craft.campaign.getAllMailingLists() %}
<pre>
{% for list in mailingLists %}
{% set subscriptionStatus = contact.getMailingListSubscriptionStatus(list.id) %}
* {{ list.title }} | {{ subscriptionStatus }}
{% endfor %}
</pre>

But I guess there isn't an easy way to actually make the form update these subscriptions..? (use case: now that we know we have a real user, it should maybe be possible to (un)subscribe to some or all available lists without getting verification emails.. I see it might be possible by trying to replicating some functionality from templates/contacts/_edit.html – but it seems a bit complicated..

@putyourlightson
Copy link
Collaborator

putyourlightson commented Nov 8, 2018

I understand your use case, but there are a few different things at play here which need to be taken into consideration (GDPR, GeoIP, etc.). I'm reluctant to add this functionality to the update-contact controller action as it will require duplication of functionality as well as some workarounds and may bloat the codebase.

In terms of implementation, you could set up a simple AJAX call to the tracker controller if a user wants to subscribe or unsubscribe from a list. Here's an untested example using jQuery:

<a href="#" class="subscribe" data-mailingList="mailing-list-slug" data-email="me@email.com">Subscribe</a>

<script>
    $('.subscribe').click(function() {
        var data = {
            mailingList: $(this).attr('data-mailingList'),
            email: $(this).attr('data-email'),
        };
        data[csrfTokenName] = csrfTokenValue;
        $.post('/actions/campaign/t/subscribe', data);
    });
</script>

@putyourlightson
Copy link
Collaborator

I'm ready to release this, just want to make sure you're satisfied with the additions and functionality?

@phoob
Copy link
Contributor Author

phoob commented Nov 9, 2018

yes, thanks! awesome :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant