summaryrefslogtreecommitdiffstats
path: root/wp-inst/wp-register.php
diff options
context:
space:
mode:
Diffstat (limited to 'wp-inst/wp-register.php')
-rw-r--r--wp-inst/wp-register.php129
1 files changed, 72 insertions, 57 deletions
diff --git a/wp-inst/wp-register.php b/wp-inst/wp-register.php
index 4a3e0d3..327c7fc 100644
--- a/wp-inst/wp-register.php
+++ b/wp-inst/wp-register.php
@@ -14,47 +14,52 @@ case 'register':
$user_login = sanitize_user( $_POST['user_login'] );
$user_email = $_POST['user_email'];
+
+ $errors = array();
if ( $user_login == '' )
- die (__('<strong>ERROR</strong>: Please enter a username.'));
+ $errors['user_login'] = __('<strong>ERROR</strong>: Please enter a username.');
/* checking e-mail address */
if ($user_email == '') {
- die (__('<strong>ERROR</strong>: Please type your e-mail address.'));
+ $errors['user_email'] = __('<strong>ERROR</strong>: Please type your e-mail address.');
} else if (!is_email($user_email)) {
- die (__('<strong>ERROR</strong>: The email address isn&#8217;t correct.'));
+ $errors['user_email'] = __('<strong>ERROR</strong>: The email address isn&#8217;t correct.');
}
- if ( username_exists( $user_login ) )
- die (__('<strong>ERROR</strong>: This username is already registered, please choose another one.'));
+ if ( username_exists( $user_login ) )
+ $errors['user_login'] = __('<strong>ERROR</strong>: This username is already registered, please choose another one.');
- $user_level = get_settings('new_users_can_blog');
$password = substr( md5( uniqid( microtime() ) ), 0, 7);
- $user_id = create_user( $user_login, $password, $user_email, $user_level );
-
- do_action('user_register', $user_id);
-
+ $user_id = create_user( $user_login, $password, $user_email, 0 );
if ( !$user_id ) {
- die (sprintf(__('<strong>ERROR</strong>: Couldn&#8217;t register you... please contact the <a href="mailto:%s">webmaster</a> !'), get_settings('admin_email')));
+ $errors['user_id'] = sprintf(__('<strong>ERROR</strong>: Couldn&#8217;t register you... please contact the <a href="mailto:%s">webmaster</a> !'), get_settings('admin_email'));
}
- $stars = '';
- for ($i = 0; $i < strlen($pass1); $i = $i + 1) {
- $stars .= '*';
- }
+ if(count($errors) == 0) {
+ $user = new WP_User($user_id);
+ $user->set_role(get_settings('default_role'));
- $message = sprintf(__('Username: %s'), $user_login) . "\r\n";
- $message .= sprintf(__('Password: %s'), $password) . "\r\n";
- $message .= get_settings('siteurl') . "/wp-login.php\r\n";
+ do_action('user_register', $user_id);
- wp_mail($user_email, sprintf(__('[%s] Your username and password'), get_settings('blogname')), $message);
-
- $message = sprintf(__('New user registration on your blog %s:'), get_settings('blogname')) . "\r\n\r\n";
- $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
- $message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n";
-
- @wp_mail(get_settings('admin_email'), sprintf(__('[%s] New User Registration'), get_settings('blogname')), $message);
+
+ $stars = '';
+ for ($i = 0; $i < strlen($pass1); $i = $i + 1) {
+ $stars .= '*';
+ }
+
+ $message = sprintf(__('Username: %s'), $user_login) . "\r\n";
+ $message .= sprintf(__('Password: %s'), $password) . "\r\n";
+ $message .= get_settings('siteurl') . "/wp-login.php\r\n";
+
+ wp_mail($user_email, sprintf(__('[%s] Your username and password'), get_settings('blogname')), $message);
+
+ $message = sprintf(__('New user registration on your blog %s:'), get_settings('blogname')) . "\r\n\r\n";
+ $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
+ $message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n";
+
+ @wp_mail(get_settings('admin_email'), sprintf(__('[%s] New User Registration'), get_settings('blogname')), $message);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
@@ -81,34 +86,9 @@ case 'register':
</body>
</html>
- <?php
-break;
-
-case 'disabled':
-
- ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
- <title>WordPress &raquo; <?php _e('Registration Currently Disabled') ?></title>
- <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_settings('blog_charset'); ?>">
- <link rel="stylesheet" href="wp-admin/wp-admin.css" type="text/css">
-</head>
-
-<body>
-
-<div id="login">
- <h2><?php _e('Registration Disabled') ?></h2>
- <p><?php _e('User registration is currently not allowed.') ?><br />
- <a href="<?php echo get_settings('home') . '/'; ?>" title="<?php _e('Go back to the blog') ?>"><?php _e('Home') ?></a>
- </p>
-</div>
-
-</body>
-</html>
-
- <?php
-break;
+ <?php
+ break;
+ }
default:
@@ -130,11 +110,19 @@ default:
<div id="login">
<h1><a href="http://wordpress.org/">WordPress</a></h1>
<h2><?php _e('Register for this blog') ?></h2>
-
+<?php if ( isset($errors) ) : ?>
+<div class="error">
+ <ul>
+ <?php
+ foreach($errors as $error) echo "<li>$error</li>";
+ ?>
+ </ul>
+</div>
+<?php endif; ?>
<form method="post" action="wp-register.php" id="registerform">
<p><input type="hidden" name="action" value="register" />
- <label for="user_login"><?php _e('Username:') ?></label><br /> <input type="text" name="user_login" id="user_login" size="20" maxlength="20" /><br /></p>
- <p><label for="user_email"><?php _e('E-mail:') ?></label><br /> <input type="text" name="user_email" id="user_email" size="25" maxlength="100" /></p>
+ <label for="user_login"><?php _e('Username:') ?></label><br /> <input type="text" name="user_login" id="user_login" size="20" maxlength="20" value="<?php echo $user_login; ?>" /><br /></p>
+ <p><label for="user_email"><?php _e('E-mail:') ?></label><br /> <input type="text" name="user_email" id="user_email" size="25" maxlength="100" value="<?php echo $user_email; ?>" /></p>
<p>A password will be emailed to you.</p>
<p class="submit"><input type="submit" value="<?php _e('Register') ?> &raquo;" id="submit" name="submit" /></p>
</form>
@@ -150,5 +138,32 @@ default:
<?php
break;
+
+case 'disabled':
+
+ ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title>WordPress &raquo; <?php _e('Registration Currently Disabled') ?></title>
+ <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_settings('blog_charset'); ?>">
+ <link rel="stylesheet" href="wp-admin/wp-admin.css" type="text/css">
+</head>
+
+<body>
+
+<div id="login">
+ <h2><?php _e('Registration Disabled') ?></h2>
+ <p><?php _e('User registration is currently not allowed.') ?><br />
+ <a href="<?php echo get_settings('home') . '/'; ?>" title="<?php _e('Go back to the blog') ?>"><?php _e('Home') ?></a>
+ </p>
+</div>
+
+</body>
+</html>
+
+ <?php
+break;
+
}
-?> \ No newline at end of file
+?>