Make WordPress Core

Changeset 2704 for trunk/wp-register.php


Ignore:
Timestamp:
07/12/2005 03:53:13 PM (20 years ago)
Author:
ryan
Message:

Roles update + UI from Owen.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-register.php

    r2702 r2704  
    1515    $user_login = sanitize_user( $_POST['user_login'] );
    1616    $user_email = $_POST['user_email'];
     17   
     18    $errors = array();
    1719       
    1820    if ( $user_login == '' )
    19         die (__('<strong>ERROR</strong>: Please enter a username.'));
     21        $errors['user_login'] = __('<strong>ERROR</strong>: Please enter a username.');
    2022
    2123    /* checking e-mail address */
    2224    if ($user_email == '') {
    23         die (__('<strong>ERROR</strong>: Please type your e-mail address.'));
     25        $errors['user_email'] = __('<strong>ERROR</strong>: Please type your e-mail address.');
    2426    } else if (!is_email($user_email)) {
    25         die (__('<strong>ERROR</strong>: The email address isn&#8217;t correct.'));
     27        $errors['user_email'] = __('<strong>ERROR</strong>: The email address isn&#8217;t correct.');
    2628    }
    2729
    28     if ( username_exists( $user_login ) )
    29         die (__('<strong>ERROR</strong>: This username is already registered, please choose another one.'));
     30  if ( username_exists( $user_login ) )
     31        $errors['user_login'] = __('<strong>ERROR</strong>: This username is already registered, please choose another one.');
    3032
    31     $user_level = get_settings('new_users_can_blog');
    3233    $password = substr( md5( uniqid( microtime() ) ), 0, 7);
    3334
    34     $user_id = create_user( $user_login, $password, $user_email, $user_level );
    35 
    36     do_action('user_register', $user_id);
    37 
     35    $user_id = create_user( $user_login, $password, $user_email, 0 );
    3836    if ( !$user_id ) {
    39         die (sprintf(__('<strong>ERROR</strong>: Couldn&#8217;t register you... please contact the <a href="mailto:%s">webmaster</a> !'), get_settings('admin_email')));
     37        $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'));
    4038    }
    4139
    42     $stars = '';
    43     for ($i = 0; $i < strlen($pass1); $i = $i + 1) {
    44         $stars .= '*';
    45     }
     40    if(count($errors) == 0) {
     41        $user = new WP_User($user_id);
     42        $user->set_role(get_settings('default_role'));
    4643   
    47     $message  = sprintf(__('Username: %s'), $user_login) . "\r\n";
    48     $message .= sprintf(__('Password: %s'), $password) . "\r\n";
    49     $message .= get_settings('siteurl') . "/wp-login.php\r\n";
     44        do_action('user_register', $user_id);
    5045   
    51     wp_mail($user_email, sprintf(__('[%s] Your username and password'), get_settings('blogname')), $message);
    52 
    53     $message  = sprintf(__('New user registration on your blog %s:'), get_settings('blogname')) . "\r\n\r\n";
    54     $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
    55     $message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n";
    56 
    57     @wp_mail(get_settings('admin_email'), sprintf(__('[%s] New User Registration'), get_settings('blogname')), $message);
     46   
     47        $stars = '';
     48        for ($i = 0; $i < strlen($pass1); $i = $i + 1) {
     49            $stars .= '*';
     50        }
     51       
     52        $message  = sprintf(__('Username: %s'), $user_login) . "\r\n";
     53        $message .= sprintf(__('Password: %s'), $password) . "\r\n";
     54        $message .= get_settings('siteurl') . "/wp-login.php\r\n";
     55       
     56        wp_mail($user_email, sprintf(__('[%s] Your username and password'), get_settings('blogname')), $message);
     57   
     58        $message  = sprintf(__('New user registration on your blog %s:'), get_settings('blogname')) . "\r\n\r\n";
     59        $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
     60        $message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n";
     61   
     62        @wp_mail(get_settings('admin_email'), sprintf(__('[%s] New User Registration'), get_settings('blogname')), $message);
    5863
    5964    ?>
     
    8287</html>
    8388
     89        <?php
     90        break;
     91    }
     92
     93default:
     94
     95?>
     96<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     97<html xmlns="http://www.w3.org/1999/xhtml">
     98<head>
     99    <title>WordPress &raquo; <?php _e('Registration Form') ?></title>
     100    <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_settings('blog_charset'); ?>" />
     101    <link rel="stylesheet" href="wp-admin/wp-admin.css" type="text/css" />
     102    <style type="text/css">
     103    #user_email, #user_login, #submit {
     104        font-size: 1.7em;
     105    }
     106    </style>
     107</head>
     108
     109<body>
     110<div id="login">
     111<h1><a href="http://wordpress.org/">WordPress</a></h1>
     112<h2><?php _e('Register for this blog') ?></h2>
     113<?php if ( isset($errors) ) : ?>
     114<div class="error">
     115    <ul>
    84116    <?php
     117    foreach($errors as $error) echo "<li>$error</li>";
     118    ?>
     119    </ul>
     120</div>
     121<?php endif; ?>
     122<form method="post" action="wp-register.php" id="registerform">
     123    <p><input type="hidden" name="action" value="register" />
     124    <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>
     125    <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>
     126    <p>A password will be emailed to you.</p>
     127    <p class="submit"><input type="submit" value="<?php _e('Register') ?> &raquo;" id="submit" name="submit" /></p>
     128</form>
     129<ul>
     130    <li><a href="<?php bloginfo('home'); ?>" title="<?php _e('Are you lost?') ?>">&laquo; <?php _e('Back to blog') ?></a></li>
     131    <li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php"><?php _e('Login') ?></a></li>
     132    <li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php?action=lostpassword" title="<?php _e('Password Lost and Found') ?>"><?php _e('Lost your password?') ?></a></li>
     133</ul>
     134</div>
     135
     136</body>
     137</html>
     138<?php
     139
    85140break;
    86141
     
    111166break;
    112167
    113 default:
    114 
    115 ?>
    116 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    117 <html xmlns="http://www.w3.org/1999/xhtml">
    118 <head>
    119     <title>WordPress &raquo; <?php _e('Registration Form') ?></title>
    120     <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_settings('blog_charset'); ?>" />
    121     <link rel="stylesheet" href="wp-admin/wp-admin.css" type="text/css" />
    122     <style type="text/css">
    123     #user_email, #user_login, #submit {
    124         font-size: 1.7em;
    125     }
    126     </style>
    127 </head>
    128 
    129 <body>
    130 <div id="login">
    131 <h1><a href="http://wordpress.org/">WordPress</a></h1>
    132 <h2><?php _e('Register for this blog') ?></h2>
    133 
    134 <form method="post" action="wp-register.php" id="registerform">
    135     <p><input type="hidden" name="action" value="register" />
    136     <label for="user_login"><?php _e('Username:') ?></label><br /> <input type="text" name="user_login" id="user_login" size="20" maxlength="20" /><br /></p>
    137     <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>
    138     <p>A password will be emailed to you.</p>
    139     <p class="submit"><input type="submit" value="<?php _e('Register') ?> &raquo;" id="submit" name="submit" /></p>
    140 </form>
    141 <ul>
    142     <li><a href="<?php bloginfo('home'); ?>" title="<?php _e('Are you lost?') ?>">&laquo; <?php _e('Back to blog') ?></a></li>
    143     <li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php"><?php _e('Login') ?></a></li>
    144     <li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php?action=lostpassword" title="<?php _e('Password Lost and Found') ?>"><?php _e('Lost your password?') ?></a></li>
    145 </ul>
    146 </div>
    147 
    148 </body>
    149 </html>
    150 <?php
    151 
    152 break;
    153168}
    154169?>
Note: See TracChangeset for help on using the changeset viewer.