Home › Forums › Newsletter Plugin Support › how to trigger the opt-in email, when subscribing via ajax?
- This topic has 5 replies, 2 voices, and was last updated 7 years ago by
jnz.
-
AuthorPosts
-
November 8, 2016 at 5:46 pm #27027
jnz
Participanthi and thanks for stopping by. i created this little snippet of documentation on how to insert emails via ajax. finding out by now, that this doesn’t trigger the opt-in emails. is there some sort of action that i can run, to send out this email? i searched the plugin but couldn’t find anything about it. some sort of action would be grrrreat..?! (btw. my doc lacks some infos, i could complete those, but for better reading i would post this all in one answer. i’d be willing to do so, if you let me do it.. also i think, this question has to be dealt with first, since its also neccessary..) thanks. jnz.
November 8, 2016 at 6:56 pm #27028Stefano
KeymasterYou can call directly the http://domain.com?na=s, state you disable the anto bot protection in the subscription panel and that will be a regular subscription, even if called via ajax. Of course the ajax call can ignore the returned redirect. Or you can in your code call the subscribe() method of NewsletterSubscription.
Stefano.
November 9, 2016 at 9:25 am #27050jnz
Participanthi stefano
for me in slow motion please. remeber: you wrote the plugin, i just don’t know nothing about it. so lets assume i am in functions.php, ajax is ringing and i have an email address. how do i proceed from there? subscribe() method sounds good, but how do i invoke it and what needs to be set? (this path sounds like the best one, or what do you think?)
or what does the na=s state do? i don’t get the “disable the anto bot protection” part. does that mean, that it skips double opt-in? that’s not what i want..November 9, 2016 at 4:47 pm #27056jnz
Participanthi. got it working. thanks for you input 🙂
November 9, 2016 at 5:42 pm #27060jnz
Participantall right. got it working but having another problem..
i created 6 types of lists and i want every subscriber to be in there.
under: list building > lists i created my 6 items and picked “only on profile page” & initially checked.
that doesn’t do the trick.
this is my data-array, that i submit via ajax, but that doesn’t change a bit:data: { action: 'ajax_subscribe', nonce: js_config.ajax_nonce, ne: $form.find('.newsletter-email').val(), list_1: 1, list_2: "1", list_3: true, list_4: "true", list_5: 1, list_6: 1, data: serializedData },
is it an error in the plugin, or how would i set the default lists automagically..?
thank you!!November 10, 2016 at 9:36 am #27067jnz
Participantsolved this.
the list element is called nl and accepts an array of list IDs (NOT zero indexed).nl: [1,2,3,4,5,6]
data: { action: 'ajax_subscribe', nonce: js_config.ajax_nonce, ne: $form.find('.newsletter-email').val(), nl: [1,2,3,4,5,6], data: serializedData },
-
AuthorPosts
- You must be logged in to reply to this topic.