【发布时间】:2021-02-18 19:39:05
【问题描述】:
成功结帐后,我需要使用 woocommerce 帐单电子邮件更新 WordPress 帐户电子邮件。我使用了这段代码,但它不起作用:
/* Update account email based on woocommerce billing email */
add_filter( 'woocommerce_thankyou' , 'custom_update_checkout_fields', 10, 2 );
function custom_update_checkout_fields($user_id, $old_user_data ) {
$current_user = wp_get_current_user();
// Updating Billing info
if($current_user->user_email != $current_user->billing_email)
update_user_meta($user_id, 'billing_email', $current_user->user_email);
}
我是否使用过时的代码?
【问题讨论】:
标签: php wordpress woocommerce orders usermetadata