errors['empty_email']); } // Skip random password if a password was entered in a form add_filter('random_password','oe_reg_password'); function oe_reg_password($password){ $pass = filter_input(INPUT_POST, 'user_pass'); if( ! empty( $pass ) ) $password = $pass; return $password; } /* * Register form * Fields validation */ add_filter('registration_errors','oe_registration_errors'); function oe_registration_errors($errors){ // Removes empty email error unset($errors->errors['empty_email']); $pass1 = filter_input(INPUT_POST, 'user_pass'); $pass2 = filter_input(INPUT_POST, 'user_pass2'); // Check for blank password when adding a user. if ( empty( $pass1 ) ) { $errors->add( 'empty_pass', __( 'ERROR: Please enter a password.' ) ); } // Check for "\" in password. if ( false !== strpos( wp_unslash( $pass1 ), "\\" ) ) { $errors->add( 'incorrect_pass', __( 'ERROR: Passwords may not contain the character "\\".' ) ); } // Checking the password has been typed twice the same. if ( ! empty( $pass1 ) && $pass1 != $pass2 ) { $errors->add( 'incorrect_pass2', __( 'ERROR: Please enter the same password in both password fields.' ) ); } return $errors; } /* * MU signup form & MU Admin add new user form * Fields validation */ add_filter('wpmu_validate_user_signup','oe_mu_signup_validate'); function oe_mu_signup_validate($results){ // Skip if admin creates a new user if( is_admin() ) return $results; $email = filter_input(INPUT_POST, 'user_email'); $pass1 = filter_input(INPUT_POST, 'user_pass'); $pass2 = filter_input(INPUT_POST, 'user_pass2'); if( $results['errors']->errors['user_email'] && ! $email ) unset($results['errors']->errors['user_email']); // Check for blank password when adding a user. if ( empty( $pass1 ) ) { $results['errors']->add( 'user_pass', __( 'Please enter a password.' ) ); } // Check for "\" in password. if ( false !== strpos( wp_unslash( $pass1 ), "\\" ) ) { $results['errors']->add( 'user_pass', __( 'Passwords may not contain the character "\\".' ) ); } // Checking the password has been typed twice the same. if ( ! empty( $pass1 ) && $pass1 != $pass2 ) { $results['errors']->add( 'user_pass2', __( 'Please enter the same password in both password fields.' ) ); } return $results; } /* * Register form front-end * Adds password fields */ add_action('register_form','oe_regform_changes',1); function oe_regform_changes(){ $user_pass = filter_input(INPUT_POST, 'user_pass'); $user_pass2 = filter_input(INPUT_POST, 'user_pass2'); ?>
get_error_message('user_pass'); $errmsg2 = $errors->get_error_message('user_pass2'); $user_pass = filter_input(INPUT_POST, 'user_pass'); $user_pass2 = filter_input(INPUT_POST, 'user_pass2'); ?>