I found the stored Donor META data in phpMyAdmin ‘wp_xxxxxx_give_donormeta’ table, however I am still unable to retrieve this information into an email upon submit.
If there is a way to retrieve the same information from within Donations WordPress admin this would also be acceptable solution.
Pulling up phpMyAdmin is not practical.
I’m also using Stripe payment if that helps.
One more try, but no luck with following:
https://givewp.com/documentation/developers/how-to-add-custom-email-tags/
This did not return any results
/**
* Adds a Custom "Occupation" Tag
*
* This function creates a custom GiveWP email template tag.
*/
function my_custom_prefix_add_occupation_tag() {
give_add_email_tag(
array(
'tag' => 'my-occupation-tag', // The tag name.
'desc' => __( 'This outputs the Occupation', 'give' ), // For admins.
'func' => 'my_custom_prefix_get_donation_occupation_info', // Callback to function below.
'context' => 'general', // 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', 'my_custom_prefix_add_occupation_tag' );
/**
* Get Custom Occupation Message
*
* Example function that returns custom field data if present in payment_meta;
* The example used here is in conjunction with the GiveWP documentation tutorials.
*
* @param array $tag_args Array of arguments
*
* @return string
*/
function my_custom_prefix_get_donation_occupation_info( $tag_args ) {
// Update get meta request to get your custom data. You can pull from payment meta, donor meta, or other custom meta.
$my-occupation-tag = give_get_meta( $tag_args['payment_id'], 'give_occupation', true );
$output = __( 'No Occupation message :(', 'give' ); // Fallback message. (optional)
if ( ! empty( $my-occupation-tag ) ) {
$output = wp_kses_post( $my-occupation-tag );
}
return $output;
}
Hi @mallamace,
I tested your snippet and the {my-occupation-tag} outputs the occupation without any additional code.
Here’s a quick screencast to demonstrate: https://somup.com/c3Qr2oUCHu
Triple-check that there are not typos in your email template. Also check the template in HTML view to make sure the formatting is not getting in the way.
If you still cannot get it to work, the last snippet you posted should do the trick but you need to fix it a bit.
The give_get_meta() function queries the donation meta, not the donor meta. So you need to get the donor id from the payment meta and then use that to query the donor meta for the value you are looking for.
So change this line:
$my-occupation-tag = give_get_meta( $tag_args['payment_id'], 'give_occupation', true );
to this:
$donorID = give_get_payment_meta($tag_args['payment_id'], '_give_payment_donor_id');
$my-occupation-tag = Give()->donor_meta->get_meta($donorID, 'Occupation', true);
Hope that helps.
Hi there,
Just checking in on this issue. Do you still need assistance here?
If you still need help, reply and we’ll make sure everything is handled.