]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/network/user-new.php
Wordpress 3.1.1-scripts
[autoinstalls/wordpress.git] / wp-admin / network / user-new.php
1 <?php
2 /**
3  * Add Site Administration Screen
4  *
5  * @package WordPress
6  * @subpackage Multisite
7  * @since 3.1.0
8  */
9
10 /** Load WordPress Administration Bootstrap */
11 require_once( './admin.php' );
12
13 if ( ! is_multisite() )
14         wp_die( __( 'Multisite support is not enabled.' ) );
15
16 if ( ! current_user_can('create_users') )
17         wp_die(__('You do not have sufficient permissions to add users to this network.'));
18
19
20 add_contextual_help($current_screen,
21         '<p>' . __('Add User will set up a new user account on the network and send them an email with their username and password.') . '</p>' .
22         '<p>' . __('Users who are signed up to the network without a site are added as subscribers to the main or primary dashboard site, giving them profile pages to manage their accounts. These users will only see Dashboard and My Sites in the main navigation until a site is created for them.') . '</p>' .
23         '<p><strong>' . __('For more information:') . '</strong></p>' .
24         '<p>' . __('<a href="http://codex.wordpress.org/Network_Admin_Users_Screen" target="_blank">Documentation on Network Users</a>') . '</p>' .
25         '<p>' . __('<a href="http://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>') . '</p>'
26 );
27
28 if ( isset($_REQUEST['action']) && 'add-user' == $_REQUEST['action'] ) {
29         check_admin_referer( 'add-user', '_wpnonce_add-user' );
30         if ( ! current_user_can( 'manage_network_users' ) )
31                 wp_die( __( 'You do not have permission to access this page.' ) );
32
33         if ( is_array( $_POST['user'] ) == false )
34                 wp_die( __( 'Cannot create an empty user.' ) );
35         $user = $_POST['user'];
36         if ( empty($user['username']) && empty($user['email']) )
37                 wp_die( __( 'Missing username and email.' ) );
38         elseif ( empty($user['username']) )
39                 wp_die( __( 'Missing username.' ) );
40         elseif ( empty($user['email']) )
41                 wp_die( __( 'Missing email.' ) );
42
43         $password = wp_generate_password( 12, false);
44         $user_id = wpmu_create_user( esc_html( strtolower( $user['username'] ) ), $password, esc_html( $user['email'] ) );
45
46         if ( false == $user_id )
47                 wp_die( __( 'Duplicated username or email address.' ) );
48         else
49                 wp_new_user_notification( $user_id, $password );
50                 
51         wp_redirect( add_query_arg( array('update' => 'added'), 'user-new.php' ) );
52         exit;
53 }
54
55 if ( isset($_GET['update']) ) {
56         $messages = array();
57         if ( 'added' == $_GET['update'] )
58                 $messages[] = __('User added.');
59 }
60
61 $title = __('Add New User');
62 $parent_file = 'users.php';
63
64 require('../admin-header.php'); ?>
65
66 <div class="wrap">
67 <?php screen_icon(); ?>
68 <h2 id="add-new-user"><?php _e('Add New User') ?></h2>
69 <?php
70 if ( ! empty( $messages ) ) {
71         foreach ( $messages as $msg )
72                 echo '<div id="message" class="updated"><p>' . $msg . '</p></div>';
73 } ?>
74         <form action="<?php echo network_admin_url('user-new.php?action=add-user'); ?>" id="adduser" method="post">     
75         <table class="form-table">
76                 <tr class="form-field form-required">
77                         <th scope="row"><?php _e( 'Username' ) ?></th>
78                         <td><input type="text" class="regular-text" name="user[username]" /></td>
79                 </tr>
80                 <tr class="form-field form-required">
81                         <th scope="row"><?php _e( 'Email' ) ?></th>
82                         <td><input type="text" class="regular-text" name="user[email]" /></td>
83                 </tr>
84                 <tr class="form-field">
85                         <td colspan="2"><?php _e( 'Username and password will be mailed to the above email address.' ) ?></td>
86                 </tr>
87         </table>
88         <?php wp_nonce_field( 'add-user', '_wpnonce_add-user' ) ?>
89         <?php submit_button( __('Add User'), 'primary', 'add-user' ); ?>
90         </form>
91 </div>
92 <?php
93 require('../admin-footer.php');
94 ?>