大多数国家的互联网网站立法都禁止这样做,而电子商务业务的立法则更为严厉(欧盟国家对此更加严格并且立场强硬)。客户有权访问/更改/删除其数据。
当帐单电子邮件已存在时,要从“我的帐户编辑地址和结帐”中删除帐单电子邮件地址,请使用以下命令:
add_filter( 'woocommerce_billing_fields', 'disable_billing_email_changes' );
function disable_billing_email_changes( $billing_fields ) {
$billing_email = WC()->customer->get_billing_email();
// If email ealready xists
if ($billing_email) {
unset($billing_fields["billing_email"]); // Remove billing email field
}
return $billing_fields;
}
代码位于活动子主题的functions.php 文件中(或插件中)。经过测试并有效。
要删除或隐藏用户电子邮件(如果已存在),请从“我的帐户”帐户详细信息部分中,您必须通过您的子主题覆盖 https://woocommerce.com/document/template-structure/, 模板文件myaccount/form-edit-account.php https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/templates/myaccount/form-edit-account.php.
您将替换:
<p class="woocommerce-form-row woocommerce-form-row--wide form-row form-row-wide">
<label for="account_email"><?php esc_html_e( 'Email address', 'woocommerce' ); ?> <span class="required">*</span></label>
<input type="email" class="woocommerce-Input woocommerce-Input--email input-text" name="account_email" id="account_email" autocomplete="email" value="<?php echo esc_attr( $user->user_email ); ?>" />
</p>
具有以下内容:
<?php $current_user = wp_get_current_user();
if ( ! $current_user->user_email ) : ?>
<p class="woocommerce-form-row woocommerce-form-row--wide form-row form-row-wide">
<label for="account_email"><?php esc_html_e( 'Email address', 'woocommerce' ); ?> <span class="required">*</span></label>
<input type="email" class="woocommerce-Input woocommerce-Input--email input-text" name="account_email" id="account_email" autocomplete="email" value="<?php echo esc_attr( $user->user_email ); ?>" />
</p>
<?php endif; ?>