Cannot Login using Elementor Login Form
-
Hi,
I am facing a very strange issue with Elementor Login Form (Elementor Add-ons > Elements > Login | Signup Form). Issue description is as follows:
– I am the admin, when I tried to login, I am able to login but some team members are not able to login. When they try to login, it flashes and shows the same login page again with URL “/?login=failed”. But credentials are correct.
– When a new user gets created, they receive a email verification link, that link is redirecting to the login page where user cannot login. (Most probably the same reason as previous one)
I noticed this issue when I made some changes in functions.php file to allow only strong passwords in signup form. In order to achieve that, I added following code:
“””add_action(‘user_register’, ‘enforce_strong_password_for_elementor’, 10, 1);
function enforce_strong_password_for_elementor($user_id) {
if (!isset($_POST[‘password’])) {
return; // If no password is provided, exit
}$password = sanitize_text_field($_POST['password']); // Password strength regex: // Minimum 8 characters, at least one uppercase, one lowercase, one number, and one special character $pattern = '/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*#?&^%])[A-Za-z\d@$!%*#?&^%]{8,}$/'; if (!preg_match($pattern, $password)) { // Delete the user that was just created require_once(ABSPATH.'wp-admin/includes/user.php'); wp_delete_user($user_id); // Show error message wp_die( 'Error: Password must be at least 8 characters long, contain at least one uppercase letter, one lowercase letter, one number, and one special character.', 'Weak Password', array('back_link' => true) ); }}
add_action(‘user_profile_update_errors’, ‘enforce_strong_password_on_profile_update’, 10, 3);
function enforce_strong_password_on_profile_update($errors, $update, $user) {
if (!$update) return;if (isset($_POST['pass1']) && !empty($_POST['pass1'])) { $password = sanitize_text_field($_POST['pass1']); $pattern = '/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*#?&^%])[A-Za-z\d@$!%*#?&^%]{8,}$/'; if (!preg_match($pattern, $password)) { $errors->add( 'weak_password', __('Error: Password must be at least 8 characters long and include an uppercase letter, a lowercase letter, a number, and a special character.') ); } }}
add_action(‘woocommerce_save_account_details’, ‘enforce_strong_password_woocommerce’, 10, 1);
function enforce_strong_password_woocommerce($user_id) {
if (!isset($_POST[‘password_1’]) || empty($_POST[‘password_1’])) {
return;
}$password = sanitize_text_field($_POST['password_1']); $pattern = '/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*#?&^%])[A-Za-z\d@$!%*#?&^%]{8,}$/'; if (!preg_match($pattern, $password)) { wc_add_notice( 'Error: Password must be at least 8 characters long and include uppercase, lowercase, number, and special character.', 'error' ); // Prevent form from saving remove_action('woocommerce_save_account_details', 'enforce_strong_password_woocommerce', 10); }}
add_action(‘validate_password_reset’, ‘enforce_strong_password_on_reset’, 10, 2);
function enforce_strong_password_on_reset($errors, $user) {
if (!empty($_POST[‘pass1’])) {
$password = sanitize_text_field($_POST[‘pass1’]);
$pattern = ‘/^(?=.[a-z])(?=.[A-Z])(?=.\d)(?=.[@$!%#?&^%])[A-Za-z\d@$!%#?&^%]{8,}$/’;
if (!preg_match($pattern, $password)) {
$errors->add(‘weak_password’, ‘Error: Password must be strong (8+ chars, upper, lower, number, special char).’);
}
}
}”””
Even I removed this code from functions.php and cleared every possible cache, but still having the same issue. Could you help me with it?
The topic ‘Cannot Login using Elementor Login Form’ is closed to new replies.