Skip to content

Instantly share code, notes, and snippets.

@rickalday
Last active June 15, 2020 21:28
Show Gist options
  • Save rickalday/cfd5add6c49f708425834897c251eb6f to your computer and use it in GitHub Desktop.
Save rickalday/cfd5add6c49f708425834897c251eb6f to your computer and use it in GitHub Desktop.
GiveWP Anonymous Donation Email Tag
<?php
// Plugin Name: GiveWP Add Email Tag for Anonymous Checkbox
function give_anonymous_email_tag( $email_tags ) {
// Adds an email tag called {give_anonymous_status} to indicate whether the donor opted in or not.
$email_tags[] = array(
'tag' => 'give_anonymous_status', // The tag name.
'desc' => __( 'This outputs whether the donor opted-in to the anonymous option', 'give' ), // For admins.
'func' => 'render_give_anonymous_status_email_tag', // Callback to function below.
'context' => 'donation',
);
return $email_tags;
}
add_filter( 'give_email_tags', 'give_anonymous_email_tag', 999, 1 );
function render_give_anonymous_status_email_tag( $tag_args ) {
$opt_in_meta = give_get_meta( $tag_args['payment_id'], '_give_anonymous_donation', true );
if ( $opt_in_meta ) {
$output = __( 'Anonymous donation', 'give' );
} else {
$output = __( 'Not an anonymous donation', 'give' );
}
return apply_filters( 'give_email_tag_give_anonymous_status', $output, $tag_args );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment