Created
January 17, 2020 20:29
-
-
Save rickalday/6a87fe46c7d90f6cebbd15b5535f3589 to your computer and use it in GitHub Desktop.
GiveWP custom Tributes email tag
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function add_give_honoree_name_tag() { | |
| give_add_email_tag( | |
| array( | |
| 'tag' => 'honoree_fullname', // The tag name. | |
| 'desc' => __( 'The full name of the honoree.', 'give-tributes' ), | |
| 'func' => 'custom_tribute_tag_honoree_fullname', // Callback to function below. | |
| 'context' => 'donation', // This tag can be for both admin and donor notifications. | |
| 'is_admin' => false, // default is false. This is here to simply display it as an option. | |
| ) | |
| ); | |
| } | |
| add_action( 'give_add_email_tags', 'add_give_honoree_name_tag' ); | |
| function custom_tribute_tag_honoree_fullname( $tag_args ) { | |
| $payment_id = $tag_args['payment_id']; | |
| // Honoree First name. | |
| $honoree_first_name = give_get_meta( $payment_id, '_give_tributes_first_name', true ); | |
| $honoree_first_name = ! empty( $honoree_first_name ) ? $honoree_first_name : ''; | |
| // Honoree last name. | |
| $honoree_last_name = give_get_meta( $payment_id, '_give_tributes_last_name', true ); | |
| $honoree_last_name = ! empty( $honoree_last_name ) ? $honoree_last_name : ''; | |
| // Prepare Honoree Full name. | |
| if ( ! empty( $honoree_first_name ) || ! empty( $honoree_last_name ) ) { | |
| $honoree_full_name = $honoree_first_name . ' ' . $honoree_last_name; | |
| } else { | |
| $honoree_full_name = ''; | |
| } | |
| return ! empty( $honoree_full_name ) ? ucfirst( $honoree_full_name ) : ''; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment