Home Forums Newsletter Plugin Support how to trigger the opt-in email, when subscribing via ajax?

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #27027
    jnz
    Participant

    hi 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.

    #27028
    Stefano
    Keymaster

    You 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.

    #27050
    jnz
    Participant

    hi 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..

    #27056
    jnz
    Participant

    hi. got it working. thanks for you input 🙂

    #27060
    jnz
    Participant

    all 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!!

    #27067
    jnz
    Participant

    solved 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
    },
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.