When an order is placed in WooCommerce, you might want to change/add something in the User Meta programmatically.

For example, you could β€œcheck” a custom checkbox in the User Profile. Or maybe assign the User Twitter username. And so on πŸ™‚

WooCommerce: edit user meta after successful checkout

PHP Snippet: Update User Meta After a Successful Order in WooCommerce

 * @snippet       Update User Meta After a Successful Order - WooCommerce
 * @how-to        Get CustomizeWoo.com FREE
 * @sourcecode    https://businessbloomer.com/?p=21955
 * @author        Rodolfo Melogli
 * @compatible    WC 3.6.4

add_action( 'woocommerce_thankyou', 'bbloomer_checkout_save_user_meta');

function bbloomer_checkout_save_user_meta( $order_id ) {
	$order = wc_get_order( $order_id );
	$user_id = $order->get_user_id();
	if ( $order->get_total() > 100 ) {  // Define your condition here
		update_user_meta( $user_id, 'custom_checkbox', 'on');



Leave a Reply