Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

205
Views
How to login with only email and password in WooCommerce

Plugin Name: WooCommerce

plugins\woocommerce\templates\global\form-login.php

<label for="username"><?php _e( 'Email', 'woocommerce' ); ?> <span class="required">*</span></label>

It display email instead of username or email which i wanted

includes\class-wc-form-handler.php

if ( empty( $username ) ) {
    throw new Exception( '<strong>' . __( 'Error:', 'woocommerce' ) . '</strong> ' . __( 'Email is required.', 'woocommerce' ) );
}

It display validation for email correct but it login with username also

I want it to login only with email and password before checkout

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

If you look closely at wp-content/plugins/woocommerce/includes/class-wc-form-handler.php at line num 878 there is a filter woocommerce_process_login_errors, which accepts validations error, username and password. So you can overwrite this by this filter help.

Here is the code:

// define the woocommerce_process_login_errors callback 
function filter_woocommerce_process_login_errors($validation_error, $post_username, $post_password)
{
    //if (strpos($post_username, '@') == FALSE)
    if (!filter_var($post_username, FILTER_VALIDATE_EMAIL)) //<--recommend option
    {
        throw new Exception( '<strong>' . __( 'Error', 'woocommerce' ) . ':</strong> ' . __( 'Please Enter a Valid Email ID.', 'woocommerce' ) );
    }
    return $validation_error;
}

// add the filter 
add_filter('woocommerce_process_login_errors', 'filter_woocommerce_process_login_errors', 10, 3);

Code goes in functions.php file of your active child theme (or theme). Or also in any plugin php files.
Code is tested and works. in WooCommerce 2.6.X

Hope this helps!

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!