Home Forums Newsletter Plugin Support Help for little filter newsletter_subscription code

  • This topic has 2 replies, 2 voices, and was last updated 1 week ago by User.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #350602
    User
    Participant

    Hello everyone !
    I need a little help to write some code, I use a plug in to get email when people download something. this plugin triggers this:

    /**
    * Triggers at the end of processing the subscription form successfully *
    * @param array $form_data
    do_action(‘std_end_form_process’, $form_data, $form_details);
    the mail is in $form_data[‘std_email’]

    I saw there is this filter “newsletter_subscription”, and I tried but with no success to add the mail to the subscribers of newsletter ?
    could you help me I think I miss some informations, like the list or where to put the email and couldn’t find it in the documentation…
    thanks in advance !!!

    in the doc I saw this exemple.. I just want to add $form_data[‘std_email’] to a specific list for instance…

    add_filter(“newsletter_subscription”, “my_filter_newsletter_subscription”, 10, 2);
    function my_filter_newsletter_replace($subscription, $user) {

    // Another filter nulled the subscription
    if (!$subscription) {
    return $subscription;
    }

    // Just an example: if the subscriber exists, force the single opt-in
    if ($user) {
    $subscription->optin = ‘single’;
    }

    // Never forget the return!
    return $subscription;
    }

    Thanks in advance for any help 🙂 !!
    Daniel

    #350631
    Michael
    Keymaster

    Hello Daniel,

    I’ve shared this with our developers, but unfortunately we cannot help with custom code at this time. Anyway, that filter would trigger only when a subscription is performed through one of our forms. Are you using a form creation plugin?

    Michael

    #350658
    User
    Participant

    no worries, chatgpt helped me and I could do what I want 🙂 🙂 cheers

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.