Last active
March 31, 2018 14:44
-
-
Save Qoraiche/b8a6c4f51996160fde41480ad6fdef9e to your computer and use it in GitHub Desktop.
Woocommerce_subscription when a payment is made on a subscription
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
/* | |
* woocommerce_subscription_payment_complete action hook | |
* Triggered when a payment is made on a subscription | |
* @param $subscription | |
*/ | |
add_action( 'woocommerce_subscription_payment_complete', 'update_user', 10, 1 ); | |
function update_user($subscription) { | |
// Getting the user ID from the current subscription object | |
$user_id = get_post_meta($subscription->ID, '_customer_user', true); | |
// add user meta when user_type not defined | |
$user_type = get_user_meta($user_id, 'user_plan_type' , false); | |
update_user_meta( $user_id, 'user_plan_type' , 'pro' ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment