When a customer edits/updates their billing email address, or billing name, through the WooCommerce “edit billing details” section, this function will also automatically update their WordPress email address and/or name.
This code snippet is over a year old, from before WooCommerce 2.0. I don’t know if this function works with WooCommerce 2.0+.
/** ** ** update WordPress user email, first and last name when customer edit's billing email address on woocommerce account ** **/ add_action( 'woocommerce_customer_save_address','isa_customer_save_address', 10, 1); function isa_customer_save_address() { global $woocommerce; $user_id = get_current_user_id(); wp_update_user( array ( 'ID' => $user_id, 'user_email' => $_POST['billing_email'] ) ) ; wp_update_user( array ( 'ID' => $user_id, 'first_name' => $_POST['billing_first_name'] ) ) ; wp_update_user( array ( 'ID' => $user_id, 'last_name' => $_POST['billing_last_name'] ) ) ; }
clickmac
June 9th, 2013 at 5:00 pm
hmm i don’t think it does work 🙁 but i am searching across the internet to just make this function work:
My aim is echo the current guest or logged in user saved last name on the product page. This user made a order already, so the saved meta data from the checkout page, I would like to use.
Aryan Duntley
July 31st, 2013 at 8:17 am
You need to use get_user_meta, not get_post_meta. . .
Santiago
May 19th, 2015 at 9:11 pm
Incredible, you have helped me a lot. You don´t know how much.
Thanks a lot,
Santiago
Litbea
November 20th, 2015 at 12:36 am
It’s working for me on WC 2.4.8!
Frank
December 9th, 2015 at 4:00 pm
Works one way (profile get updated with billinng infos), but cans it goes both ways? Is the billing name and last name can be sync with the profile?
Diego G
July 2nd, 2016 at 1:07 pm
Yes, can be sync.
Amity Web Solutions
June 28th, 2017 at 11:10 am
But billing name is part of the address and the user could have multiple addresses, so how does this work when having multiple billing addresses with different names?
Thanks
luke
July 30th, 2019 at 4:19 am
I cannot get this to work. Does this still work?