Add new user page

git-svn-id: http://svn.automattic.com/wordpress/trunk@9614 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-11-11 19:47:22 +00:00
parent e635db2ee6
commit 0a23990c2a
4 changed files with 140 additions and 94 deletions

View File

@ -316,7 +316,7 @@ function page_comments_status_meta_box($post){
<p><?php _e('These settings apply to this page only. &#8220;Pings&#8221; are <a href="http://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments" target="_blank">trackbacks and pingbacks</a>.'); ?></p>
<?php
}
add_meta_box('pagecommentstatusdiv', __('Comments &amp; Pings'), 'page_comments_status_meta_box', 'page', 'normal', 'core');
add_meta_box('pagecommentstatusdiv', __('Discussion'), 'page_comments_status_meta_box', 'page', 'normal', 'core');
/**
* Display page slug form fields.

View File

@ -78,7 +78,8 @@ else
if ( current_user_can('edit_users') ) {
$_wp_real_parent_file['profile.php'] = 'users.php'; // Back-compat for plugins adding submenus to profile.php.
$submenu['users.php'][5] = array(__('Authors &amp; Users'), 'edit_users', 'users.php');
$submenu['users.php'][10] = array(__('Your Profile'), 'read', 'profile.php');
$submenu['users.php'][10] = array(__('Add New'), 'create_users', 'user-new.php');
$submenu['users.php'][15] = array(__('Your Profile'), 'read', 'profile.php');
} else {
$_wp_real_parent_file['users.php'] = 'profile.php';
$submenu['profile.php'][5] = array(__('Your Profile'), 'read', 'profile.php');

137
wp-admin/user-new.php Normal file
View File

@ -0,0 +1,137 @@
<?php
/**
* New User Administration Panel.
*
* @package WordPress
* @subpackage Administration
*/
/** WordPress Administration Bootstrap */
require_once('admin.php');
if ( !current_user_can('create_users') )
wp_die(__('Cheatin&#8217; uh?'));
/** WordPress Registration API */
require_once( ABSPATH . WPINC . '/registration.php');
if ( isset($_REQUEST['action']) && 'adduser' == $_REQUEST['action'] ) {
check_admin_referer('add-user');
if ( ! current_user_can('create_users') )
wp_die(__('You can&#8217;t create users.'));
$user_id = add_user();
$update = 'add';
if ( is_wp_error( $user_id ) )
$add_user_errors = $user_id;
else {
$new_user_login = apply_filters('pre_user_login', sanitize_user(stripslashes($_REQUEST['user_login']), true));
$redirect = add_query_arg( array('usersearch' => urlencode($new_user_login), 'update' => $update), $redirect );
wp_redirect( $redirect . '#user-' . $user_id );
die();
}
}
$title = __('Add New User');
$parent_file = 'users.php';
wp_enqueue_script('admin-users');
wp_enqueue_script('admin-forms');
require_once ('admin-header.php');
screen_meta('user');
?>
<div class="wrap">
<h2 id="add-new-user"><?php _e('Add New User') ?></h2>
<?php if ( isset($errors) && is_wp_error( $errors ) ) : ?>
<div class="error">
<ul>
<?php
foreach ( $errors->get_error_messages() as $err )
echo "<li>$err</li>\n";
?>
</ul>
</div>
<?php endif;
if ( ! empty($messages) ) {
foreach ( $messages as $msg )
echo $msg;
} ?>
<?php if ( isset($add_user_errors) && is_wp_error( $add_user_errors ) ) : ?>
<div class="error">
<?php
foreach ( $add_user_errors->get_error_messages() as $message )
echo "<p>$message</p>";
?>
</div>
<?php endif; ?>
<div id="ajax-response"></div>
<?php
if ( get_option('users_can_register') )
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>';
else
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>';
?>
<form action="#add-new-user" method="post" name="adduser" id="adduser" class="add:users: validate">
<?php wp_nonce_field('add-user') ?>
<table class="form-table">
<tr class="form-field form-required">
<th scope="row"><label for="user_login"><?php _e('Username (required)') ?></label><input name="action" type="hidden" id="action" value="adduser" /></th>
<td ><input name="user_login" type="text" id="user_login" value="<?php echo $new_user_login; ?>" aria-required="true" /></td>
</tr>
<tr class="form-field">
<th scope="row"><label for="first_name"><?php _e('First Name') ?> </label></th>
<td><input name="first_name" type="text" id="first_name" value="<?php echo $new_user_firstname; ?>" /></td>
</tr>
<tr class="form-field">
<th scope="row"><label for="last_name"><?php _e('Last Name') ?> </label></th>
<td><input name="last_name" type="text" id="last_name" value="<?php echo $new_user_lastname; ?>" /></td>
</tr>
<tr class="form-field form-required">
<th scope="row"><label for="email"><?php _e('E-mail (required)') ?></label></th>
<td><input name="email" type="text" id="email" value="<?php echo $new_user_email; ?>" /></td>
</tr>
<tr class="form-field">
<th scope="row"><label for="url"><?php _e('Website') ?></label></th>
<td><input name="url" type="text" id="url" value="<?php echo $new_user_uri; ?>" /></td>
</tr>
<?php if ( apply_filters('show_password_fields', true) ) : ?>
<tr class="form-field form-required">
<th scope="row"><label for="pass1"><?php _e('Password (twice)') ?> </label></th>
<td><input name="pass1" type="password" id="pass1" autocomplete="off" />
<br />
<input name="pass2" type="password" id="pass2" autocomplete="off"/></td>
</tr>
<?php endif; ?>
<tr class="form-field">
<th scope="row"><label for="role"><?php _e('Role'); ?></label></th>
<td><select name="role" id="role">
<?php
if ( !$new_user_role )
$new_user_role = $current_role ? $current_role : get_option('default_role');
wp_dropdown_roles($new_user_role);
?>
</select>
</td>
</tr>
</table>
<p class="submit">
<?php echo $referer; ?>
<input name="adduser" type="submit" id="addusersub" class="button" value="<?php _e('Add User') ?>" />
</p>
</form>
</div>
<?php
include('admin-footer.php');
?>

View File

@ -176,23 +176,6 @@ case 'delete':
break;
case 'adduser':
check_admin_referer('add-user');
if ( ! current_user_can('create_users') )
wp_die(__('You can&#8217;t create users.'));
$user_id = add_user();
$update = 'add';
if ( is_wp_error( $user_id ) )
$add_user_errors = $user_id;
else {
$new_user_login = apply_filters('pre_user_login', sanitize_user(stripslashes($_REQUEST['user_login']), true));
$redirect = add_query_arg( array('usersearch' => urlencode($new_user_login), 'update' => $update), $redirect );
wp_redirect( $redirect . '#user-' . $user_id );
die();
}
default:
if ( !empty($_GET['_wp_http_referer']) ) {
@ -407,82 +390,7 @@ foreach ( $wp_user_search->get_results() as $userid ) {
?>
<br class="clear" />
<?php if ( current_user_can('create_users') ) { ?>
<div class="wrap">
<h2 id="add-new-user"><?php _e('Add New User') ?></h2>
<?php if ( isset($add_user_errors) && is_wp_error( $add_user_errors ) ) : ?>
<div class="error">
<?php
foreach ( $add_user_errors->get_error_messages() as $message )
echo "<p>$message</p>";
?>
</div>
<?php endif; ?>
<div id="ajax-response"></div>
<?php
if ( get_option('users_can_register') )
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>';
else
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>';
?>
<form action="#add-new-user" method="post" name="adduser" id="adduser" class="add:users: validate">
<?php wp_nonce_field('add-user') ?>
<table class="form-table">
<tr class="form-field form-required">
<th scope="row"><label for="user_login"><?php _e('Username (required)') ?></label><input name="action" type="hidden" id="action" value="adduser" /></th>
<td ><input name="user_login" type="text" id="user_login" value="<?php echo $new_user_login; ?>" aria-required="true" /></td>
</tr>
<tr class="form-field">
<th scope="row"><label for="first_name"><?php _e('First Name') ?> </label></th>
<td><input name="first_name" type="text" id="first_name" value="<?php echo $new_user_firstname; ?>" /></td>
</tr>
<tr class="form-field">
<th scope="row"><label for="last_name"><?php _e('Last Name') ?> </label></th>
<td><input name="last_name" type="text" id="last_name" value="<?php echo $new_user_lastname; ?>" /></td>
</tr>
<tr class="form-field form-required">
<th scope="row"><label for="email"><?php _e('E-mail (required)') ?></label></th>
<td><input name="email" type="text" id="email" value="<?php echo $new_user_email; ?>" /></td>
</tr>
<tr class="form-field">
<th scope="row"><label for="url"><?php _e('Website') ?></label></th>
<td><input name="url" type="text" id="url" value="<?php echo $new_user_uri; ?>" /></td>
</tr>
<?php if ( apply_filters('show_password_fields', true) ) : ?>
<tr class="form-field form-required">
<th scope="row"><label for="pass1"><?php _e('Password (twice)') ?> </label></th>
<td><input name="pass1" type="password" id="pass1" autocomplete="off" />
<br />
<input name="pass2" type="password" id="pass2" autocomplete="off"/></td>
</tr>
<?php endif; ?>
<tr class="form-field">
<th scope="row"><label for="role"><?php _e('Role'); ?></label></th>
<td><select name="role" id="role">
<?php
if ( !$new_user_role )
$new_user_role = $current_role ? $current_role : get_option('default_role');
wp_dropdown_roles($new_user_role);
?>
</select>
</td>
</tr>
</table>
<p class="submit">
<?php echo $referer; ?>
<input name="adduser" type="submit" id="addusersub" class="button" value="<?php _e('Add User') ?>" />
</p>
</form>
</div>
<?php
}
break;
} // end of the $doaction switch