通过 WooCommerce 注册时将完整的电子邮件地址设置为用户名 [英] Set full email address as username when registering through WooCommerce

查看:29
本文介绍了通过 WooCommerce 注册时将完整的电子邮件地址设置为用户名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

WooCommerce 在设置/帐户下有一个名为

WooCommerce under Settings/Account has an option named

从客户电子邮件中自动生成用户名

Automatically generate username from customer email

但它生成的用户名不是完整的电子邮件地址.

but the username it generates is not the full email address.

my.email@example.com

成为 myemail 作为用户名.

我需要挂钩什么方法来覆盖用户生成,以便完整的电子邮件被设置为用户名?

What method would I need to hook into to override the user generation so that the full email is set as the username?

推荐答案

只需使用钩子 pre_user_login

add_filter( 'pre_user_login' , 'wpso_same_user_email' );

function wpso_same_user_email( $user_login ) {

    if( isset($_POST['billing_email'] ) ) {
        $user_login = $_POST['billing_email'];
    }
    if( isset($_POST['email'] ) ) {
        $user_login = $_POST['email'];
    }
    return $user_login;
}

这篇关于通过 WooCommerce 注册时将完整的电子邮件地址设置为用户名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆