Skip to content

Instantly share code, notes, and snippets.

@JarrydLong
Created April 9, 2025 12:43
Show Gist options
  • Save JarrydLong/66a8bab50ccbf6ccbf2a52588cdbff48 to your computer and use it in GitHub Desktop.
Save JarrydLong/66a8bab50ccbf6ccbf2a52588cdbff48 to your computer and use it in GitHub Desktop.
<?php //do not copy
/**
* This recipe gets a customer's Tax ID and country from the webhook
*
* Create two User fields with the names pmpro_stripe_tax_type and pmpro_stripe_tax_id to view
* the tax type and tax ID in the member's profile.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function mypmpro_webhook_data( $event){
if( empty( $event->data->object->customer_tax_ids ) || empty( $event->data->object->id ) ){
return;
}
$tax_ids = reset( $event->data->object->customer_tax_ids );
$tax_type = $tax_ids['type'];
$tax_id = $tax_ids['value'];
$order = new MemberOrder();
$order->getMemberOrderByPaymentTransactionID( $event->data->object->id );
$user_id = $order->user_id;
update_user_meta( $user_id, 'pmpro_stripe_tax_type', $tax_type );
update_user_meta( $user_id, 'pmpro_stripe_tax_id', $tax_id );
}
add_action( 'pmpro_stripe_webhook_event_received', 'mypmpro_webhook_data', 10, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment