Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save salehahmadbabu/840195551a92efa4f71046e2de3ef8ae to your computer and use it in GitHub Desktop.
Save salehahmadbabu/840195551a92efa4f71046e2de3ef8ae to your computer and use it in GitHub Desktop.
add_action( 'woocommerce_order_status_changed', 'your_function', 99, 4 );
function your_function( $order_id, $old_status, $new_status, $order ){
if( $new_status == "completed" ) {
var_dump($order);
$user_id = $order->get_user_id();
$user = new WP_User($user_id);
$user->set_role('subscriber');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment