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’ 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’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 wp_enqueue_script('admin-users');
mp-wp_genesis 40
mp-wp_genesis 41 require_once ('admin-header.php');
mp-wp_genesis 42
mp-wp_genesis 43 ?>
mp-wp_genesis 44 <div class="wrap">
mp-wp_genesis 45 <?php screen_icon(); ?>
mp-wp_genesis 46 <h2 id="add-new-user"><?php _e('Add New User') ?></h2>
mp-wp_genesis 47
mp-wp_genesis 48 <?php if ( isset($errors) && is_wp_error( $errors ) ) : ?>
mp-wp_genesis 49 <div class="error">
mp-wp_genesis 50 <ul>
mp-wp_genesis 51 <?php
mp-wp_genesis 52 foreach ( $errors->get_error_messages() as $err )
mp-wp_genesis 53 echo "<li>$err</li>\n";
mp-wp_genesis 54 ?>
mp-wp_genesis 55 </ul>
mp-wp_genesis 56 </div>
mp-wp_genesis 57 <?php endif;
mp-wp_genesis 58
mp-wp_genesis 59 if ( ! empty($messages) ) {
mp-wp_genesis 60 foreach ( $messages as $msg )
mp-wp_genesis 61 echo $msg;
mp-wp_genesis 62 } ?>
mp-wp_genesis 63
mp-wp_genesis 64 <?php if ( isset($add_user_errors) && is_wp_error( $add_user_errors ) ) : ?>
mp-wp_genesis 65 <div class="error">
mp-wp_genesis 66 <?php
mp-wp_genesis 67 foreach ( $add_user_errors->get_error_messages() as $message )
mp-wp_genesis 68 echo "<p>$message</p>";
mp-wp_genesis 69 ?>
mp-wp_genesis 70 </div>
mp-wp_genesis 71 <?php endif; ?>
mp-wp_genesis 72 <div id="ajax-response"></div>
mp-wp_genesis 73
mp-wp_genesis 74 <?php
mp-wp_genesis 75 if ( get_option('users_can_register') )
mp-wp_genesis 76 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 77 else
mp-wp_genesis 78 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 79 ?>
mp-wp_genesis 80 <form action="#add-new-user" method="post" name="adduser" id="adduser" class="add:users: validate">
mp-wp_genesis 81 <?php wp_nonce_field('add-user') ?>
mp-wp_genesis 82 <?php
mp-wp_genesis 83 //Load up the passed data, else set to a default.
mp-wp_genesis 84 foreach ( array('user_login' => 'login', 'first_name' => 'firstname', 'last_name' => 'lastname',
mp-wp_genesis 85 'email' => 'email', 'url' => 'uri', 'role' => 'role') as $post_field => $var ) {
mp-wp_genesis 86 $var = "new_user_$var";
mp-wp_genesis 87 if ( ! isset($$var) )
mp-wp_genesis 88 $$var = isset($_POST[$post_field]) ? stripslashes($_POST[$post_field]) : '';
mp-wp_genesis 89 }
mp-wp_genesis 90 ?>
mp-wp_genesis 91 <table class="form-table">
mp-wp_genesis 92 <tr class="form-field form-required">
mp-wp_genesis 93 <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 94 <td ><input name="user_login" type="text" id="user_login" value="<?php echo $new_user_login; ?>" aria-required="true" /></td>
mp-wp_genesis 95 </tr>
mp-wp_genesis 96 <tr class="form-field">
mp-wp_genesis 97 <th scope="row"><label for="first_name"><?php _e('First Name') ?> </label></th>
mp-wp_genesis 98 <td><input name="first_name" type="text" id="first_name" value="<?php echo $new_user_firstname; ?>" /></td>
mp-wp_genesis 99 </tr>
mp-wp_genesis 100 <tr class="form-field">
mp-wp_genesis 101 <th scope="row"><label for="last_name"><?php _e('Last Name') ?> </label></th>
mp-wp_genesis 102 <td><input name="last_name" type="text" id="last_name" value="<?php echo $new_user_lastname; ?>" /></td>
mp-wp_genesis 103 </tr>
mp-wp_genesis 104 <tr class="form-field form-required">
mp-wp_genesis 105 <th scope="row"><label for="email"><?php _e('E-mail (required)') ?></label></th>
mp-wp_genesis 106 <td><input name="email" type="text" id="email" value="<?php echo $new_user_email; ?>" /></td>
mp-wp_genesis 107 </tr>
mp-wp_genesis 108 <tr class="form-field">
mp-wp_genesis 109 <th scope="row"><label for="url"><?php _e('Website') ?></label></th>
mp-wp_genesis 110 <td><input name="url" type="text" id="url" value="<?php echo $new_user_uri; ?>" /></td>
mp-wp_genesis 111 </tr>
mp-wp_genesis 112
mp-wp_genesis 113 <?php if ( apply_filters('show_password_fields', true) ) : ?>
mp-wp_genesis 114 <tr class="form-field form-required">
mp-wp_genesis 115 <th scope="row"><label for="pass1"><?php _e('Password (twice)') ?> </label></th>
mp-wp_genesis 116 <td><input name="pass1" type="password" id="pass1" autocomplete="off" />
mp-wp_genesis 117 <br />
mp-wp_genesis 118 <input name="pass2" type="password" id="pass2" autocomplete="off"/></td>
mp-wp_genesis 119 </tr>
mp-wp_genesis 120 <?php endif; ?>
mp-wp_genesis 121
mp-wp_genesis 122 <tr class="form-field">
mp-wp_genesis 123 <th scope="row"><label for="role"><?php _e('Role'); ?></label></th>
mp-wp_genesis 124 <td><select name="role" id="role">
mp-wp_genesis 125 <?php
mp-wp_genesis 126 if ( !$new_user_role )
mp-wp_genesis 127 $new_user_role = !empty($current_role) ? $current_role : get_option('default_role');
mp-wp_genesis 128 wp_dropdown_roles($new_user_role);
mp-wp_genesis 129 ?>
mp-wp_genesis 130 </select>
mp-wp_genesis 131 </td>
mp-wp_genesis 132 </tr>
mp-wp_genesis 133 </table>
mp-wp_genesis 134 <p class="submit">
mp-wp_genesis 135 <input name="adduser" type="submit" id="addusersub" class="button-primary" value="<?php _e('Add User') ?>" />
mp-wp_genesis 136 </p>
mp-wp_genesis 137 </form>
mp-wp_genesis 138
mp-wp_genesis 139 </div>
mp-wp_genesis 140
mp-wp_genesis 141 <?php
mp-wp_genesis 142 include('admin-footer.php');
mp-wp_genesis 143 ?>