New user registration tweaks.
git-svn-id: http://svn.automattic.com/wordpress/trunk@642 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
63f1c3e3cf
commit
723bae7219
|
@ -19,7 +19,78 @@ for ($i=0; $i<count($wpvarstoreset); $i += 1) {
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
|
case 'adduser':
|
||||||
|
$standalone = 1;
|
||||||
|
require_once('admin-header.php');
|
||||||
|
function filter($value) {
|
||||||
|
return ereg('^[a-zA-Z0-9\_-\|]+$',$value);
|
||||||
|
}
|
||||||
|
|
||||||
|
$user_login = $HTTP_POST_VARS['user_login'];
|
||||||
|
$pass1 = $HTTP_POST_VARS['pass1'];
|
||||||
|
$pass2 = $HTTP_POST_VARS['pass2'];
|
||||||
|
$user_email = $HTTP_POST_VARS['email'];
|
||||||
|
$user_firstname = $HTTP_POST_VARS['firstname'];
|
||||||
|
$user_lastname = $HTTP_POST_VARS['lastname'];
|
||||||
|
|
||||||
|
/* checking login has been typed */
|
||||||
|
if ($user_login == '') {
|
||||||
|
die ('<strong>ERROR</strong>: Please enter a login.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/* checking the password has been typed twice */
|
||||||
|
if ($pass1 == '' || $pass2 == '') {
|
||||||
|
die ('<strong>ERROR</strong>: Please enter your password twice.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/* checking the password has been typed twice the same */
|
||||||
|
if ($pass1 != $pass2) {
|
||||||
|
die ('<strong>ERROR</strong>: Please type the same password in the two password fields.');
|
||||||
|
}
|
||||||
|
$user_nickname = $user_login;
|
||||||
|
|
||||||
|
/* checking e-mail address */
|
||||||
|
if ($user_email == '') {
|
||||||
|
die ('<strong>ERROR</strong>: Please type your e-mail address.');
|
||||||
|
} else if (!is_email($user_email)) {
|
||||||
|
die ('<strong>ERROR</strong>: The email address isn’t correct.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/* checking the login isn't already used by another user */
|
||||||
|
$loginthere = $wpdb->get_var("SELECT user_login FROM $tableusers WHERE user_login = '$user_login'");
|
||||||
|
if ($loginthere) {
|
||||||
|
die ('<strong>ERROR</strong>: This login is already registered, please choose another one.');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$user_login = addslashes(stripslashes($user_login));
|
||||||
|
$pass1 = addslashes(stripslashes($pass1));
|
||||||
|
$user_nickname = addslashes(stripslashes($user_nickname));
|
||||||
|
$user_firstname = addslashes(stripslashes($user_firstname));
|
||||||
|
$user_lastname = addslashes(stripslashes($user_lastname));
|
||||||
|
$now = current_time('mysql');
|
||||||
|
|
||||||
|
$result = $wpdb->query("INSERT INTO $tableusers
|
||||||
|
(user_login, user_pass, user_nickname, user_email, user_ip, user_domain, user_browser, dateYMDhour, user_level, user_idmode, user_firstname, user_lastname)
|
||||||
|
VALUES
|
||||||
|
('$user_login', '$pass1', '$user_nickname', '$user_email', '$user_ip', '$user_domain', '$user_browser', '$now', '$new_users_can_blog', 'nickname', '$user_firstname', '$user_lastname')");
|
||||||
|
|
||||||
|
if ($result == false) {
|
||||||
|
die ('<strong>ERROR</strong>: Couldn’t register you... please contact the <a href="mailto:'.$admin_email.'">webmaster</a> !');
|
||||||
|
}
|
||||||
|
|
||||||
|
$stars = '';
|
||||||
|
for ($i = 0; $i < strlen($pass1); $i = $i + 1) {
|
||||||
|
$stars .= '*';
|
||||||
|
}
|
||||||
|
|
||||||
|
$message = "New user registration on your blog $blogname:\r\n\r\n";
|
||||||
|
$message .= "Login: $user_login\r\n\r\nE-mail: $user_email";
|
||||||
|
|
||||||
|
@mail($admin_email, "[$blogname] New User Registration", $message);
|
||||||
|
header('Location: users.php');
|
||||||
|
break;
|
||||||
|
|
||||||
case 'promote':
|
case 'promote':
|
||||||
|
|
||||||
$standalone = 1;
|
$standalone = 1;
|
||||||
|
@ -90,7 +161,7 @@ default:
|
||||||
<th>Nickname</th>
|
<th>Nickname</th>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th>E-mail</th>
|
<th>E-mail</th>
|
||||||
<th>URL</th>
|
<th>URI</th>
|
||||||
<th>Level</th>
|
<th>Level</th>
|
||||||
<th>Posts</th>
|
<th>Posts</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -143,7 +214,7 @@ default:
|
||||||
<th>Nickname</th>
|
<th>Nickname</th>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th>E-mail</th>
|
<th>E-mail</th>
|
||||||
<th>URL</th>
|
<th>URI</th>
|
||||||
<th>Level</th>
|
<th>Level</th>
|
||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
|
@ -185,6 +256,40 @@ echo "\n<tr $style>
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<h2>Add User</h2>
|
<h2>Add User</h2>
|
||||||
<p>Users can <a href="<?php echo $siteurl ?>/wp-register.php">register themselves</a> or you can manually create users here.</p>
|
<p>Users can <a href="<?php echo $siteurl ?>/wp-register.php">register themselves</a> or you can manually create users here.</p>
|
||||||
|
<form action="" method="post" name="adduser" id="adduser">
|
||||||
|
<table border="0" cellspacing="5" cellpadding="3">
|
||||||
|
<tr>
|
||||||
|
<th scope="row">Nickname
|
||||||
|
<input name="action" type="hidden" id="action" value="adduser" /></th>
|
||||||
|
<td><input name="user_login" type="text" id="user_login" /></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">First Name </th>
|
||||||
|
<td><input name="firstname" type="text" id="firstname" /></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">Last Name </th>
|
||||||
|
<td><input name="lastname" type="text" id="lastname" /></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">Email</th>
|
||||||
|
<td><input name="email" type="text" id="email" /></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">URI</th>
|
||||||
|
<td><input name="uri" type="text" id="uri" /></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">Password (twice) </th>
|
||||||
|
<td><input name="pass1" type="text" id="pass1" />
|
||||||
|
<br />
|
||||||
|
<input name="pass2" type="text" id="pass2" /></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<p>
|
||||||
|
<input name="adduser" type="submit" id="adduser" value="Add User">
|
||||||
|
</p>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,6 @@ case 'register':
|
||||||
$pass1 = $HTTP_POST_VARS['pass1'];
|
$pass1 = $HTTP_POST_VARS['pass1'];
|
||||||
$pass2 = $HTTP_POST_VARS['pass2'];
|
$pass2 = $HTTP_POST_VARS['pass2'];
|
||||||
$user_email = $HTTP_POST_VARS['user_email'];
|
$user_email = $HTTP_POST_VARS['user_email'];
|
||||||
$user_login = $HTTP_POST_VARS['user_login'];
|
|
||||||
|
|
||||||
/* checking login has been typed */
|
/* checking login has been typed */
|
||||||
if ($user_login == '') {
|
if ($user_login == '') {
|
||||||
|
@ -88,11 +87,12 @@ case 'register':
|
||||||
$user_login = addslashes($user_login);
|
$user_login = addslashes($user_login);
|
||||||
$pass1 = addslashes($pass1);
|
$pass1 = addslashes($pass1);
|
||||||
$user_nickname = addslashes($user_nickname);
|
$user_nickname = addslashes($user_nickname);
|
||||||
|
$now = current_time('mysql');
|
||||||
|
|
||||||
$result = $wpdb->query("INSERT INTO $tableusers
|
$result = $wpdb->query("INSERT INTO $tableusers
|
||||||
(user_login, user_pass, user_nickname, user_email, user_ip, user_domain, user_browser, dateYMDhour, user_level, user_idmode)
|
(user_login, user_pass, user_nickname, user_email, user_ip, user_domain, user_browser, dateYMDhour, user_level, user_idmode)
|
||||||
VALUES
|
VALUES
|
||||||
('$user_login', '$pass1', '$user_nickname', '$user_email', '$user_ip', '$user_domain', '$user_browser', NOW(), '$new_users_can_blog', 'nickname')");
|
('$user_login', '$pass1', '$user_nickname', '$user_email', '$user_ip', '$user_domain', '$user_browser', '$now', '$new_users_can_blog', 'nickname')");
|
||||||
|
|
||||||
if ($result == false) {
|
if ($result == false) {
|
||||||
die ('<strong>ERROR</strong>: Couldn’t register you... please contact the <a href="mailto:'.$admin_email.'">webmaster</a> !');
|
die ('<strong>ERROR</strong>: Couldn’t register you... please contact the <a href="mailto:'.$admin_email.'">webmaster</a> !');
|
||||||
|
|
Loading…
Reference in New Issue