Created
March 28, 2025 00:13
-
-
Save rickalday/44ac8616f4e661b279d6a4d37bfd59b8 to your computer and use it in GitHub Desktop.
Incluir DNI en recibo PDF
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
<?php | |
function givewp_pdf_nifnie_tag( $template_content, $args ) { | |
$meta_keys = ['nifnie', 'dninie', 'dniniecif']; | |
$buyer_info = give_get_payment_meta_user_info( $args['donation_id'] ); | |
$post = get_post($args['donation_id']); | |
if ($post->post_parent) { | |
$post_id = $post->post_parent; | |
} else { | |
$post_id = $args['donation_id']; | |
} | |
$nifnie = ''; | |
foreach ($meta_keys as $key) { | |
$nifnie_value = get_post_meta($post_id, $key, true); | |
if (!empty($nifnie_value)) { | |
$nifnie = $nifnie_value; | |
} | |
} | |
$template_content = str_replace( '{nifnie}', $nifnie, $template_content ); | |
return $template_content; | |
} | |
add_filter( 'give_pdf_compiled_template_content', 'givewp_pdf_nifnie_tag', 900, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment