Last active
November 13, 2023 06:00
-
-
Save clifgriffin/697d99bc221739e67065cc953cbb70f7 to your computer and use it in GitHub Desktop.
Force WooCommerce to use email address as username when registering new accounts.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Do NOT include the opening php tag. | |
// Place in your theme's functions.php file | |
add_filter( 'woocommerce_new_customer_data', function( $data ) { | |
$data['user_login'] = $data['user_email']; | |
return $data; | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's not the most rational approach to insert your code directly into the functions.php file. This is because it might be overwritten during theme updates.
Probably the best option is to use a snippet plugin like Code Snippets or WPCode. These plugins allow you to add and manage code snippets easily, without directly modifying theme files.
Alternatively, you can consider adding your code snippets to the functions.php file of a child theme. This way, your customizations are not likely to be affected by theme updates, providing a more stable and update-friendly solution 🙂