Changeset 12722 for trunk/wp-admin/user-new.php
- Timestamp:
- 01/14/2010 02:02:19 AM (16 years ago)
- Location:
- trunk/wp-admin
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
user-new.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin
-
Property
svn:ignore
set to
.themes.php.swp
.user-edit.php.swp
.user-new.php.swp
.users.php.swp
-
Property
svn:ignore
set to
-
trunk/wp-admin/user-new.php
r11369 r12722 16 16 require_once( ABSPATH . WPINC . '/registration.php'); 17 17 18 if ( is_multisite() ) { 19 function admin_created_user_email( $text ) { 20 return sprintf( __( "Hi, 21 You've been invited to join '%s' at 22 %s as a %s. 23 If you do not want to join this blog please ignore 24 this email. This invitation will expire in a few days. 25 26 Please click the following link to activate your user account: 27 %%s" ), get_bloginfo('name'), site_url(), wp_specialchars( $_REQUEST[ 'role' ] ) ); 28 } 29 add_filter( 'wpmu_signup_user_notification_email', 'admin_created_user_email' ); 30 31 function admin_created_user_subject( $text ) { 32 return "[" . get_bloginfo('name') . "] Your blog invite"; 33 } 34 } 35 18 36 if ( isset($_REQUEST['action']) && 'adduser' == $_REQUEST['action'] ) { 19 37 check_admin_referer('add-user'); … … 22 40 wp_die(__('You can’t create users.')); 23 41 24 $user_id = add_user(); 25 26 if ( is_wp_error( $user_id ) ) { 27 $add_user_errors = $user_id; 42 if ( !is_multisite() ) { 43 $user_id = add_user(); 44 45 if ( is_wp_error( $user_id ) ) { 46 $add_user_errors = $user_id; 47 } else { 48 $new_user_login = apply_filters('pre_user_login', sanitize_user(stripslashes($_REQUEST['user_login']), true)); 49 $redirect = 'users.php?usersearch='. urlencode($new_user_login) . '&update=add'; 50 wp_redirect( $redirect . '#user-' . $user_id ); 51 die(); 52 } 28 53 } 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(); 54 $user_login = preg_replace( "/\s+/", '', sanitize_user( $_REQUEST[ 'user_login' ], true ) ); 55 $user_details = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->users} WHERE user_login = %s AND user_email = %s", $user_login, $_REQUEST[ 'email' ] ) ); 56 if( $user_details ) { 57 // Adding an existing user to this blog 58 $new_user_email = wp_specialchars(trim($_REQUEST['email'])); 59 $redirect = 'user-new.php'; 60 $username = $user_details->user_login; 61 $user_id = $user_details->ID; 62 if( ($username != null && is_site_admin( $username ) == false ) && ( array_key_exists($blog_id, get_blogs_of_user($user_id)) ) ) { 63 $redirect = add_query_arg( array('update' => 'addexisting'), 'user-new.php' ); 64 } else { 65 if ( isset( $_POST[ 'noconfirmation' ] ) && is_site_admin() ) { 66 add_existing_user_to_blog( array( 'user_id' => $user_id, 'role' => $_REQUEST[ 'role' ] ) ); 67 $redirect = add_query_arg( array('update' => 'addnoconfirmation'), 'user-new.php' ); 68 } else { 69 $newuser_key = substr( md5( $user_id ), 0, 5 ); 70 add_option( 'new_user_' . $newuser_key, array( 'user_id' => $user_id, 'email' => $user_details->user_email, 'role' => $_REQUEST[ 'role' ] ) ); 71 $message = __("Hi,\n\nYou have been invited to join '%s' at\n%s as a %s.\nPlease click the following link to confirm the invite:\n%s\n"); 72 wp_mail( $new_user_email, sprintf( __( '[%s] Joining confirmation' ), get_option( 'blogname' ) ), sprintf($message, get_option('blogname'), site_url(), $_REQUEST[ 'role' ], site_url("/newbloguser/$newuser_key/"))); 73 $redirect = add_query_arg( array('update' => 'add'), 'user-new.php' ); 74 } 75 } 76 wp_redirect( $redirect ); 77 die(); 78 } else { 79 // Adding a new user to this blog 80 $user_details = wpmu_validate_user_signup( $_REQUEST[ 'user_login' ], $_REQUEST[ 'email' ] ); 81 unset( $user_details[ 'errors' ]->errors[ 'user_email_used' ] ); 82 if ( is_wp_error( $user_details[ 'errors' ] ) && !empty( $user_details[ 'errors' ]->errors ) ) { 83 $add_user_errors = $user_details[ 'errors' ]; 84 } else { 85 $new_user_login = apply_filters('pre_user_login', sanitize_user(stripslashes($_REQUEST['user_login']), true)); 86 if ( isset( $_POST[ 'noconfirmation' ] ) && is_site_admin() ) { 87 add_filter( 'wpmu_signup_user_notification', create_function('', '{return false;}') ); // Disable confirmation email 88 } 89 wpmu_signup_user( $new_user_login, $_REQUEST[ 'email' ], array( 'add_to_blog' => $wpdb->blogid, 'new_role' => $_REQUEST[ 'role' ] ) ); 90 if ( isset( $_POST[ 'noconfirmation' ] ) && is_site_admin() ) { 91 $key = $wpdb->get_var( $wpdb->prepare( "SELECT activation_key FROM {$wpdb->signups} WHERE user_login = %s AND user_email = %s", $new_user_login, $_REQUEST[ 'email' ] ) ); 92 wpmu_activate_signup( $key ); 93 $redirect = add_query_arg( array('update' => 'addnoconfirmation'), 'user-new.php' ); 94 } else { 95 $redirect = add_query_arg( array('update' => 'newuserconfimation'), 'user-new.php' ); 96 } 97 wp_redirect( $redirect ); 98 die(); 99 } 100 } 33 101 } 34 102 } … … 43 111 require_once ('admin-header.php'); 44 112 113 if ( is_multisite() ) { 114 switch( $_GET[ 'update' ] ) { 115 case "newuserconfimation": 116 $messages[] = '<div id="message" class="updated fade"><p>' . __('Invitation email sent to new user. A confirmation link must be clicked before their account is created.') . '</p></div>'; 117 break; 118 case "add": 119 $messages[] = '<div id="message" class="updated fade"><p>' . __('Invitation email sent to user. A confirmation link must be clicked for them to be added to your blog.') . '</p></div>'; 120 break; 121 case "addnoconfirmation": 122 $messages[] = '<div id="message" class="updated fade"><p>' . __('User has been added to your blog.') . '</p></div>'; 123 break; 124 case "addexisting": 125 $messages[] = '<div id="message" class="updated fade"><p>' . __('That user is already a member of this blog.') . '</p></div>'; 126 break; 127 } 128 } 45 129 ?> 46 130 <div class="wrap"> … … 75 159 76 160 <?php 161 if ( !is_multisite() ) { 77 162 if ( get_option('users_can_register') ) 78 163 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>'; 79 164 else 80 165 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>'; 166 } else { 167 echo '<p>' . __( 'You can add new users to your blog in two ways:' ) . '<ol><li> ' . __( 'Enter the username and email address of an existing user on this site.' ) . '</li><li> ' . __( 'Enter the username and the email address of a person who is not already a member of this site. Choose the username carefully, it cannot be changed.' ) . '</li></ol></p>'; 168 echo '<p>' . __( 'That person will be sent an email asking them to click a link confirming the invite. New users will then be sent an email with a randomly generated password and a login link.' ) . '</p>'; 169 } 81 170 ?> 82 171 <form action="#add-new-user" method="post" name="adduser" id="adduser" class="add:users: validate"> … … 93 182 ?> 94 183 <table class="form-table"> 184 <?php if ( !is_multisite() ) { ?> 95 185 <tr class="form-field form-required"> 96 186 <th scope="row"><label for="user_login"><?php _e('Username'); ?> <span class="description"><?php _e('(required)'); ?></span></label> … … 131 221 </tr> 132 222 <?php endif; ?> 133 223 <?php } else { // multisite ?> 224 <tr class="form-field form-required"> 225 <th scope="row"><label for="user_login"><?php _e('Username (required)') ?></label><input name="action" type="hidden" id="action" value="adduser" /></th> 226 <td ><input name="user_login" type="text" id="user_login" value="<?php echo $new_user_login; ?>" aria-required="true" /></td> 227 </tr> 228 <tr class="form-field form-required"> 229 <th scope="row"><label for="email"><?php _e('E-mail (required)') ?></label></th> 230 <td><input name="email" type="text" id="email" value="<?php echo $new_user_email; ?>" /></td> 231 </tr> 232 <?php } ?> 134 233 <tr class="form-field"> 135 234 <th scope="row"><label for="role"><?php _e('Role'); ?></label></th> … … 143 242 </td> 144 243 </tr> 244 245 <?php if ( is_multisite() && is_super_admin() ) { ?> 246 <tr class="form-field"> 247 <th scope="row"><label for="noconfirmation"><?php _e('Skip Confirmation Email') ?></label></th> 248 <td><input name="noconfirmation" type="checkbox" id="noconfirmation" value="1" /> <label for="noconfirmation"><?php _e( 'Site administrators can add a user without sending the confirmation email.' ); ?></label></td> 249 </tr> 250 <?php } ?> 145 251 </table> 146 252 <p class="submit">
Note: See TracChangeset
for help on using the changeset viewer.