woocommerce offtopic – registration_errors not working

I am trying to use the registration_errors filter to filter user registrations in a woocommerce store. But it is not working. This is the test code I am using but nothing happens:

add_filter( 'registration_errors', 'my_registration_errors', 10, 3 );

function my_registration_errors( $errors, $sanitized_user_login, $user_email ) {
    
    if ( true ) {
        $errors->add( 'error_test', 'Error message' );
    }

    return $errors;
}

I am doing user registration through /my-account/ page of Woocommerce. I don’t have any plugins other than Woocommerce and Code Snippets.

If I’m using Woocommerce, maybe I need to use some other filter?

Leave a Comment