Home Forums Newsletter Plugin Support Adding GiveWP donors to a mailing list

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #291043

    Hi there

    I still have my L plates one when it comes to coding so could really use some help getting your API to talk to GiveWP. (which unfortunately only integrates with big third party mailing systems like MailChimp, Aweber etc)

    I have added a custom field to my donate form that is a checkbox for people to tick to be added to the mailing list.

    GiveWP has a field “Do Action” which enables me to splice in some code but I haven’t the faintest idea how to map the fields from the donate form to the fields in the Newsletter plugin (which all happens so neatly when I am using an Elementor form on other pages!)

    Any help anyone can provide would be much appreciated.


    Did you get this going? If not, I will be working on it shortly since I need it as well.

    Craig Haller

    Add a radio with Yes and No and call the meta _give_want_newsletter then put this code in a snippet or functions.php

    See give/includes/payments/functions.php
    * Fires while inserting payments.
    * @param int $payment_id The payment ID.
    * @param array $payment_data Arguments passed.

    function bdn_give_insert_payment( $payment_ID, $payment_data ) {

    if ( get_post_meta( $payment_ID, ‘_give_want_newsletter’, true ) != ‘Yes’ ) return;

    // https://github.com/TheNewsletterPlugin/newsletter-codesamples/blob/master/subscribe.php
    // Please, refer to the TNP_Subscription and TNP_Subscription_Data classes of Newsletter.
    // ’email’ => NULL,’name’ => NULL,’surname’ => NULL,’sex’ => NULL,’language’ => ”,’referrer’ => NULL,’http_referrer’ => NULL,
    // ‘ip’ => NULL,’country’ => NULL,’region’ => NULL,’city’ => NULL,’lists’ =>

    // Ok, at least Newsletter should be there
    if (!class_exists(‘newsletter’)) return;
    // Optinally a version check (you should use version_compare())
    if (NEWSLETTER_VERSION < ‘7.4.0’) return;
    // This is the object representing a subscription (data and properties) to be
    // sent to Newsletter. The default one is prefilled with some attributes reflecting
    // the plugin settings (opt-mode, pre-assigned lists, …).
    $subscription = NewsletterSubscription::instance()->get_default_subscription();
    // Start filling in the subscriber data.
    $subscription->data->name = get_post_meta( $payment_ID, ‘_give_donor_billing_first_name’, true );
    $subscription->data->surname = get_post_meta( $payment_ID, ‘_give_donor_billing_last_name’, true );
    $subscription->data->email = get_post_meta( $payment_ID, ‘_give_payment_donor_email’, true ); // Of course, mandatory.

    // Lists: you integration could optionally add the subscriber to specific list. This is
    // useful to trigger other actions in Newsletter, for example starting an autoresponder series.
    // You should create a configuration side for your plugin where the administrator can select which

    // lists to activate (from 1 to 40).
    $subscription->data->lists[‘1’] = 1; // Activate list 1.
    // $subscription->data->lists[‘2’] = 0; // Deactivate list 2.

    // Subscription options
    $subscription->optin = ‘single’; // Or ‘double’. Preset following the Newsletter settings, you can comment it out.
    $subscription->send_emails = true; // Welcome or activaton emails, should be sent?
    $subscription->spamcheck = true; // Perform spam check following the rules set on Newsletter Security page?

    // Can return a WP_Error or true.
    $result = NewsletterSubscription::instance()->subscribe2($subscription);
    if (is_wp_error($result)) {
    // You can deal with the error here, but this is a in-process function, do not break the
    // flow with a die(). Do not output messages as well. Best practice is to manage the error
    // from the caller, not here.

    add_action( ‘give_insert_payment’, ‘bdn_give_insert_payment’, 10, 2 );

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