• I’m trying to add a custom field to my donation form using “My Custom Functions” plugin. All of the code below I grabbed from the givewp.com articles “Creating Custom Fields” and “Adding Custom Email Tags”.

    The comment box shows up, and you can add comments, but none of the comments appear in the “donation notification” email. The email tag called {referral} shows up in the email options in the give plugin, but for a reason beyond my coding skill level, I can’t make it work. Any help is greatly appreciated!

    I’ve looked at a bunch of articles on here and givewp and cannot seem to find it. I’ve also tweaked the code and tested it for hours and no luck there either.

    Here’s the code I’ve inputted into “My Custom Functions” to add the comment box, save the comments, and then add an email tag, and then capture the inputted comments in the email…

    function give_donation_custom_form_fields( $form_id ) {

    //Only display for a specific form;
    //Remove “If” statement to display on all forms
    {
    ?>
    <div id=”give-referral-wrap”>
    <label class=”give-label” for=”give-referral”><?php _e( ‘Comments:’, ‘give’ ); ?></label>
    <span class=”give-tooltip icon icon-question” data-tooltip=”<?php _e( ‘Comments’, ‘give’ ) ?>”></span>
    <textarea class=”give-textarea” name=”give_referral” id=”give-referral”></textarea>
    </div>
    <?php
    }//endif
    }

    add_action( ‘give_after_donation_levels’, ‘give_donation_custom_form_fields’, 10, 1 );

    /**
    * Adds a Custom “Referral” Tag
    * @description: This function creates a custom Give email template tag
    *
    * @param $payment_id
    */
    function give_add_sample_referral_tag( $payment_id ) {
    give_add_email_tag( ‘referral’, ‘give_referral’, ‘give_get_donation_referral_data’ );
    }

    add_action( ‘give_add_email_tags’, ‘give_add_sample_referral_tag’ );

    /**
    * Get Donation Referral Data
    *
    * @description Example function that returns Custom field data if present in payment_meta; the example used here is in conjunction with the Give documentation tutorials
    * @param $payment_id
    *
    * @return string|void
    */
    function give_get_donation_referral_data( $payment_id ) {

    $payment_meta = give_get_payment_meta( $payment_id );
    $output = __( ‘No referral data found.’, ‘give’ );
    if ( isset( $payment_meta[‘referral’] ) && ! empty( $payment_meta[‘referral’] ) ) {
    $output = $payment_meta[‘referral’];
    }

    return $output;
    }

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom form fields email tags not working in give donation confirmation email’ is closed to new replies.