Skip to content

Instantly share code, notes, and snippets.

@matheuswd
Created May 31, 2021 19:09
Show Gist options
  • Save matheuswd/f085abef5d766ec9030eb21e98185f8c to your computer and use it in GitHub Desktop.
Save matheuswd/f085abef5d766ec9030eb21e98185f8c to your computer and use it in GitHub Desktop.
Adds the last name tag - {donor_last_name} - to the GiveWP PDF Receipts add-on
<?php
function custom_pdf_receipt_last_name( $template_content, $args ) {
$donor_last_name = isset( $args['payment_meta']['user_info']['last_name'] ) && $args['payment_meta']['user_info']['last_name'] !== '' ? $args['payment_meta']['user_info']['last_name'] : __('Not found', 'give');
$template_content = str_replace( '{donor_last_name}', $donor_last_name, $template_content );
return $template_content;
}
add_filter( 'give_pdf_compiled_template_content', 'custom_pdf_receipt_last_name', 999, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment