raw
mp-wp_genesis           1 <?php
mp-wp_genesis 2 /**
mp-wp_genesis 3 * New User Administration Panel.
mp-wp_genesis 4 *
mp-wp_genesis 5 * @package WordPress
mp-wp_genesis 6 * @subpackage Administration
mp-wp_genesis 7 */
mp-wp_genesis 8
mp-wp_genesis 9 /** WordPress Administration Bootstrap */
mp-wp_genesis 10 require_once('admin.php');
mp-wp_genesis 11
mp-wp_genesis 12 if ( !current_user_can('create_users') )
mp-wp_genesis 13 wp_die(__('Cheatin&#8217; uh?'));
mp-wp_genesis 14
mp-wp_genesis 15 /** WordPress Registration API */
mp-wp_genesis 16 require_once( ABSPATH . WPINC . '/registration.php');
mp-wp_genesis 17
mp-wp_genesis 18 if ( isset($_REQUEST['action']) && 'adduser' == $_REQUEST['action'] ) {
mp-wp_genesis 19 check_admin_referer('add-user');
mp-wp_genesis 20
mp-wp_genesis 21 if ( ! current_user_can('create_users') )
mp-wp_genesis 22 wp_die(__('You can&#8217;t create users.'));
mp-wp_genesis 23
mp-wp_genesis 24 $user_id = add_user();
mp-wp_genesis 25
mp-wp_genesis 26 if ( is_wp_error( $user_id ) ) {
mp-wp_genesis 27 $add_user_errors = $user_id;
mp-wp_genesis 28 } else {
mp-wp_genesis 29 $new_user_login = apply_filters('pre_user_login', sanitize_user(stripslashes($_REQUEST['user_login']), true));
mp-wp_genesis 30 $redirect = 'users.php?usersearch='. urlencode($new_user_login) . '&update=add';
mp-wp_genesis 31 wp_redirect( $redirect . '#user-' . $user_id );
mp-wp_genesis 32 die();
mp-wp_genesis 33 }
mp-wp_genesis 34 }
mp-wp_genesis 35
mp-wp_genesis 36 $title = __('Add New User');
mp-wp_genesis 37 $parent_file = 'users.php';
mp-wp_genesis 38
mp-wp_genesis 39 require_once ('admin-header.php');
mp-wp_genesis 40
mp-wp_genesis 41 ?>
mp-wp_genesis 42 <div class="wrap">
mp-wp_genesis 43 <?php screen_icon(); ?>
mp-wp_genesis 44 <h2 id="add-new-user"><?php _e('Add New User') ?></h2>
mp-wp_genesis 45
mp-wp_genesis 46 <?php if ( isset($errors) && is_wp_error( $errors ) ) : ?>
mp-wp_genesis 47 <div class="error">
mp-wp_genesis 48 <ul>
mp-wp_genesis 49 <?php
mp-wp_genesis 50 foreach ( $errors->get_error_messages() as $err )
mp-wp_genesis 51 echo "<li>$err</li>\n";
mp-wp_genesis 52 ?>
mp-wp_genesis 53 </ul>
mp-wp_genesis 54 </div>
mp-wp_genesis 55 <?php endif;
mp-wp_genesis 56
mp-wp_genesis 57 if ( ! empty($messages) ) {
mp-wp_genesis 58 foreach ( $messages as $msg )
mp-wp_genesis 59 echo $msg;
mp-wp_genesis 60 } ?>
mp-wp_genesis 61
mp-wp_genesis 62 <?php if ( isset($add_user_errors) && is_wp_error( $add_user_errors ) ) : ?>
mp-wp_genesis 63 <div class="error">
mp-wp_genesis 64 <?php
mp-wp_genesis 65 foreach ( $add_user_errors->get_error_messages() as $message )
mp-wp_genesis 66 echo "<p>$message</p>";
mp-wp_genesis 67 ?>
mp-wp_genesis 68 </div>
mp-wp_genesis 69 <?php endif; ?>
mp-wp_genesis 70
mp-wp_genesis 71 <?php
mp-wp_genesis 72 if ( get_option('users_can_register') )
mp-wp_genesis 73 echo '<p>' . sprintf(__('Users can <a href="%1$s">register themselves</a> or you can manually create users here.'), site_url('wp-register.php')) . '</p>';
mp-wp_genesis 74 else
mp-wp_genesis 75 echo '<p>' . sprintf(__('Users cannot currently <a href="%1$s">register themselves</a>, but you can manually create users here.'), admin_url('options-general.php#users_can_register')) . '</p>';
mp-wp_genesis 76 ?>
mp-wp_genesis 77 <form action="#add-new-user" method="post" name="adduser" id="adduser" class="add:users: validate">
mp-wp_genesis 78 <?php wp_nonce_field('add-user') ?>
mp-wp_genesis 79 <?php
mp-wp_genesis 80 //Load up the passed data, else set to a default.
mp-wp_genesis 81 foreach ( array('user_login' => 'login', 'first_name' => 'firstname', 'last_name' => 'lastname',
mp-wp_genesis 82 'email' => 'email', 'url' => 'uri', 'role' => 'role') as $post_field => $var ) {
mp-wp_genesis 83 $var = "new_user_$var";
mp-wp_genesis 84 if ( ! isset($$var) )
mp-wp_genesis 85 $$var = isset($_POST[$post_field]) ? stripslashes($_POST[$post_field]) : '';
mp-wp_genesis 86 }
mp-wp_genesis 87 ?>
mp-wp_genesis 88 <table class="form-table">
mp-wp_genesis 89 <tr class="form-field form-required">
mp-wp_genesis 90 <th scope="row"><label for="user_login"><?php _e('Username (required)') ?></label><input name="action" type="hidden" id="action" value="adduser" /></th>
mp-wp_genesis 91 <td ><input name="user_login" type="text" id="user_login" value="<?php echo $new_user_login; ?>" aria-required="true" /></td>
mp-wp_genesis 92 </tr>
mp-wp_genesis 93 <tr class="form-field">
mp-wp_genesis 94 <th scope="row"><label for="first_name"><?php _e('First Name') ?> </label></th>
mp-wp_genesis 95 <td><input name="first_name" type="text" id="first_name" value="<?php echo $new_user_firstname; ?>" /></td>
mp-wp_genesis 96 </tr>
mp-wp_genesis 97 <tr class="form-field">
mp-wp_genesis 98 <th scope="row"><label for="last_name"><?php _e('Last Name') ?> </label></th>
mp-wp_genesis 99 <td><input name="last_name" type="text" id="last_name" value="<?php echo $new_user_lastname; ?>" /></td>
mp-wp_genesis 100 </tr>
mp-wp_genesis 101 <tr class="form-field form-required">
mp-wp_genesis 102 <th scope="row"><label for="email"><?php _e('E-mail (required)') ?></label></th>
mp-wp_genesis 103 <td><input name="email" type="text" id="email" value="<?php echo $new_user_email; ?>" /></td>
mp-wp_genesis 104 </tr>
mp-wp_genesis 105 <tr class="form-field">
mp-wp_genesis 106 <th scope="row"><label for="url"><?php _e('Website') ?></label></th>
mp-wp_genesis 107 <td><input name="url" type="text" id="url" value="<?php echo $new_user_uri; ?>" /></td>
mp-wp_genesis 108 </tr>
mp-wp_genesis 109
mp-wp_genesis 110 <?php if ( apply_filters('show_password_fields', true) ) : ?>
mp-wp_genesis 111 <tr class="form-field form-required">
mp-wp_genesis 112 <th scope="row"><label for="pass1"><?php _e('Password (twice)') ?> </label></th>
mp-wp_genesis 113 <td><input name="pass1" type="password" id="pass1" autocomplete="off" />
mp-wp_genesis 114 <br />
mp-wp_genesis 115 <input name="pass2" type="password" id="pass2" autocomplete="off"/></td>
mp-wp_genesis 116 </tr>
mp-wp_genesis 117 <?php endif; ?>
mp-wp_genesis 118
mp-wp_genesis 119 <tr class="form-field">
mp-wp_genesis 120 <th scope="row"><label for="role"><?php _e('Role'); ?></label></th>
mp-wp_genesis 121 <td><select name="role" id="role">
mp-wp_genesis 122 <?php
mp-wp_genesis 123 if ( !$new_user_role )
mp-wp_genesis 124 $new_user_role = !empty($current_role) ? $current_role : get_option('default_role');
mp-wp_genesis 125 wp_dropdown_roles($new_user_role);
mp-wp_genesis 126 ?>
mp-wp_genesis 127 </select>
mp-wp_genesis 128 </td>
mp-wp_genesis 129 </tr>
mp-wp_genesis 130 </table>
mp-wp_genesis 131 <p class="submit">
mp-wp_genesis 132 <input name="adduser" type="submit" id="addusersub" class="button-primary" value="<?php _e('Add User') ?>" />
mp-wp_genesis 133 </p>
mp-wp_genesis 134 </form>
mp-wp_genesis 135
mp-wp_genesis 136 </div>
mp-wp_genesis 137
mp-wp_genesis 138 <?php
mp-wp_genesis 139 include('admin-footer.php');