Skip to content

Instantly share code, notes, and snippets.

  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save petertwise/4a55445c78fc64a4d13183ff12c2506f 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