Better email error checking, fixes #2046

git-svn-id: https://develop.svn.wordpress.org/trunk@3507 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Matt Mullenweg 2006-02-09 08:11:26 +00:00
parent 0628227ea0
commit b17e0b1ef3
2 changed files with 14 additions and 8 deletions

View File

@ -10,6 +10,14 @@ function username_exists( $username ) {
return null; return null;
} }
function email_exists( $email ) {
global $wpdb;
$email = addslashes( $email );
$email_exists = $wpdb->get_row("SELECT user_email FROM $wpdb->users WHERE user_email = '$email'");
if ( $email_exists)
return true;
}
function validate_username( $username ) { function validate_username( $username ) {
$name = sanitize_user($username, true); $name = sanitize_user($username, true);
$valid = true; $valid = true;

View File

@ -33,10 +33,8 @@ case 'register':
if ( username_exists( $user_login ) ) if ( username_exists( $user_login ) )
$errors['user_login'] = __('<strong>ERROR</strong>: This username is already registered, please choose another one.'); $errors['user_login'] = __('<strong>ERROR</strong>: This username is already registered, please choose another one.');
/* checking the email isn't already used by another user */ if ( email_exists( $user_email ) )
$email_exists = $wpdb->get_row("SELECT user_email FROM $wpdb->users WHERE user_email = '$user_email'"); $errors['user_email'] = __('<strong>ERROR</strong>: This email is already registered, please choose another one.');
if ( $email_exists)
die (__('<strong>ERROR</strong>: This email address is already registered, please supply another.'));
if ( 0 == count($errors) ) { if ( 0 == count($errors) ) {
$password = substr( md5( uniqid( microtime() ) ), 0, 7); $password = substr( md5( uniqid( microtime() ) ), 0, 7);
@ -101,11 +99,11 @@ default:
<h2><?php _e('Register for this blog') ?></h2> <h2><?php _e('Register for this blog') ?></h2>
<?php if ( isset($errors) ) : ?> <?php if ( isset($errors) ) : ?>
<div class="error"> <div class="error">
<ul> <p>
<?php <?php
foreach($errors as $error) echo "<li>$error</li>"; foreach($errors as $error) echo "$error<br />";
?> ?>
</ul> </p>
</div> </div>
<?php endif; ?> <?php endif; ?>
<form method="post" action="wp-register.php" id="registerform"> <form method="post" action="wp-register.php" id="registerform">