Skip to content

Instantly share code, notes, and snippets.

@Qoraiche
Last active March 31, 2018 14:44
Show Gist options
  • Save Qoraiche/b8a6c4f51996160fde41480ad6fdef9e to your computer and use it in GitHub Desktop.
Save Qoraiche/b8a6c4f51996160fde41480ad6fdef9e to your computer and use it in GitHub Desktop.
Woocommerce_subscription when a payment is made on a subscription
/*
* 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