神不在的星期二
就 woo-commerce 而言,没有使用手机号码登录的默认选项。您已经在 functions.php 文件中添加了自定义函数,其中包含操作和挂钩以修改现有代码,以便能够通过手机号码登录。函数.php添加自定义字段function wooc_add_phone_number_field() { return apply_filters( 'woocommerce_forms_field', array( 'wooc_user_phone' => array( 'type' => 'text', 'label' => __( 'Phone Number', ' woocommerce' ), 'placeholder' => __( 'Your phone number', 'woocommerce' ), 'required' => true, ), ) );}add_action( 'woocommerce_register_form', 'wooc_add_field_to_registeration_form', 15 );function wooc_add_field_to_registeration_form() { $fields = wooc_add_phone_number_field(); foreach ( $fields as $key => $field_args ) { woocommerce_form_field( $key, $field_args ); }}保存到数据库add_action( 'woocommerce_created_customer', 'wooc_save_extra_register_fields' );function wooc_save_extra_register_fields( $customer_id ) { if (isset($_POST['wooc_user_phone'])){ update_user_meta( $customer_id, 'wooc_user_phone', sanitize_text_field( $_POST['wooc_user_phone'] ) ); }}