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