new file mode 100644
---wp-admin/js/user-new.dev.js (revision 0)n+++wp-admin/js/user-new.dev.js (revision 0)
@@ -0,0 +1,50 @@
+(function($){
+ var ainput = $('#adduser-email');
+ var ulist = $('#add-to-blog-users');
+
+ function add_user_to_list( dname, user_id ) {
+ /* Don't add if it already exists */
+ if ( $('#atb-user-' + user_id).length ) {
+ return;
+ }
+
+ $(ulist).append('<li class="atb-user" id="atb-user-' + user_id + '"><span class="remove"><a href="#">x</a></span> ' + dname + '</li>');
+ $(ulist).append('<input type="hidden" name="add_ids[]" id="atb-input-' + user_id + '" value="' + user_id + '" />');
+
+ $('#add-to-blog-users span.remove a').bind('click', function(){
+ remove_user_from_list( $(this).parents('.atb-user').attr('id').split('-').pop() );
+ return false;
+ });
+
+ $(ainput).val('');
+ }
+
+ function remove_user_from_list( uid ) {
+ $('#atb-user-' + uid).remove();
+ $('#atb-input-' + uid).remove();
+ }
+
+ $(document).ready(function() {
+
+ /* Prevent WP from running its form validation */
+ $('form#adduser').removeClass('validate');
+ $(ainput).parents('.form-field').removeClass('form-required');
+
+ /* Prevent WP core admin script from running */
+ /*$('form#adduser input[name="action"]').remove();*/
+
+ var options = {
+ source: ajaxurl + '?action=autocomplete_user',
+ appendTo: 'form#adduser',
+ select: function(event,ui){ add_user_to_list(ui.item.value,ui.item.id); },
+ search: function(){$(ainput).addClass('ajax-loading');},
+ open: function(){$(ainput).removeClass('ajax-loading');},
+ close: function(){$(ainput).val('');},
+ delay: 500, // miliseconds
+ };
+
+ a = $(ainput).autocomplete(options);
+ });
+
+})(jQuery);
+
|
|
Please click the following link to activate your user account: |
38 | 38 | if ( isset($_REQUEST['action']) && 'adduser' == $_REQUEST['action'] ) { |
39 | 39 | check_admin_referer( 'add-user', '_wpnonce_add-user' ); |
40 | 40 | |
41 | | $user_details = null; |
42 | | if ( false !== strpos($_REQUEST[ 'email' ], '@') ) { |
43 | | $user_details = get_user_by('email', $_REQUEST[ 'email' ]); |
| 41 | $add_users = isset( $_REQUEST['add_ids'] ) ? (array)$_REQUEST['add_ids'] : $_REQUEST['email']; |
| 42 | |
| 43 | $add_users_data = array(); |
| 44 | if ( is_array( $add_users ) ) { |
| 45 | foreach( $add_users as $add_id ) { |
| 46 | if ( current_user_can( 'promote_user', $add_id ) ) { |
| 47 | $add_users_data[] = get_userdata( (int)$add_id ); |
| 48 | } |
| 49 | } |
44 | 50 | } else { |
45 | | if ( is_super_admin() ) { |
46 | | $user_details = get_user_by('login', $_REQUEST[ 'email' ]); |
| 51 | if ( false !== strpos($add_users, '@') ) { |
| 52 | $add_users_data[] = get_user_by('email', $add_users); |
47 | 53 | } else { |
48 | | wp_redirect( add_query_arg( array('update' => 'enter_email'), 'user-new.php' ) ); |
49 | | die(); |
| 54 | if ( is_super_admin() ) { |
| 55 | $add_users_data[] = get_user_by('login', $add_users); |
| 56 | } else { |
| 57 | wp_redirect( add_query_arg( array('update' => 'enter_email'), 'user-new.php' ) ); |
| 58 | die(); |
| 59 | } |
50 | 60 | } |
| 61 | |
| 62 | if ( ! current_user_can('promote_user', $add_users_data[0]->ID) ) |
| 63 | wp_die(__('Cheatin’ uh?')); |
51 | 64 | } |
52 | 65 | |
53 | | if ( !$user_details ) { |
| 66 | if ( empty( $add_users_data ) ) { |
54 | 67 | wp_redirect( add_query_arg( array('update' => 'does_not_exist'), 'user-new.php' ) ); |
55 | 68 | die(); |
56 | 69 | } |
57 | | |
58 | | if ( ! current_user_can('promote_user', $user_details->ID) ) |
59 | | wp_die(__('Cheatin’ uh?')); |
60 | | |
61 | | // Adding an existing user to this blog |
62 | | $new_user_email = $user_details->user_email; |
63 | | $redirect = 'user-new.php'; |
64 | | $username = $user_details->user_login; |
65 | | $user_id = $user_details->ID; |
66 | | if ( ( $username != null && !is_super_admin( $user_id ) ) && ( array_key_exists($blog_id, get_blogs_of_user($user_id)) ) ) { |
67 | | $redirect = add_query_arg( array('update' => 'addexisting'), 'user-new.php' ); |
68 | | } else { |
69 | | if ( isset( $_POST[ 'noconfirmation' ] ) && is_super_admin() ) { |
70 | | add_existing_user_to_blog( array( 'user_id' => $user_id, 'role' => $_REQUEST[ 'role' ] ) ); |
71 | | $redirect = add_query_arg( array('update' => 'addnoconfirmation'), 'user-new.php' ); |
| 70 | |
| 71 | foreach( $add_users_data as $user_details ) { |
| 72 | // Adding an existing user to this blog |
| 73 | $new_user_email = $user_details->user_email; |
| 74 | $redirect = 'user-new.php'; |
| 75 | $username = $user_details->user_login; |
| 76 | $user_id = $user_details->ID; |
| 77 | if ( ( $username != null && !is_super_admin( $user_id ) ) && ( array_key_exists($blog_id, get_blogs_of_user($user_id)) ) ) { |
| 78 | $redirect = add_query_arg( array('update' => 'addexisting'), 'user-new.php' ); |
72 | 79 | } else { |
73 | | $newuser_key = substr( md5( $user_id ), 0, 5 ); |
74 | | add_option( 'new_user_' . $newuser_key, array( 'user_id' => $user_id, 'email' => $user_details->user_email, 'role' => $_REQUEST[ 'role' ] ) ); |
75 | | /* translators: 1: Site name, 2: site URL, 3: role, 4: activation URL */ |
76 | | $message = __( 'Hi, |
77 | | |
| 80 | if ( isset( $_POST[ 'noconfirmation' ] ) && is_super_admin() ) { |
| 81 | add_existing_user_to_blog( array( 'user_id' => $user_id, 'role' => $_REQUEST[ 'role' ] ) ); |
| 82 | $redirect = add_query_arg( array('update' => 'addnoconfirmation'), 'user-new.php' ); |
| 83 | } else { |
| 84 | $newuser_key = substr( md5( $user_id ), 0, 5 ); |
| 85 | add_option( 'new_user_' . $newuser_key, array( 'user_id' => $user_id, 'email' => $user_details->user_email, 'role' => $_REQUEST[ 'role' ] ) ); |
| 86 | /* translators: 1: Site name, 2: site URL, 3: role, 4: activation URL */ |
| 87 | $message = __( 'Hi, |
| 88 | |
78 | 89 | You\'ve been invited to join \'%1$s\' at |
79 | 90 | %2$s with the role of %3$s. |
80 | 91 | |
81 | 92 | Please click the following link to confirm the invite: |
82 | 93 | %4$s' ); |
83 | | wp_mail( $new_user_email, sprintf( __( '[%s] Joining confirmation' ), get_option( 'blogname' ) ), sprintf($message, get_option('blogname'), home_url(), $_REQUEST[ 'role' ], home_url("/newbloguser/$newuser_key/"))); |
84 | | $redirect = add_query_arg( array('update' => 'add'), 'user-new.php' ); |
| 94 | 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/"))); |
| 95 | $redirect = add_query_arg( array('update' => 'add'), 'user-new.php' ); |
| 96 | } |
85 | 97 | } |
86 | 98 | } |
87 | 99 | wp_redirect( $redirect ); |
… |
… |
get_current_screen()->set_help_sidebar( |
178 | 190 | |
179 | 191 | wp_enqueue_script('wp-ajax-response'); |
180 | 192 | wp_enqueue_script('user-profile'); |
| 193 | wp_enqueue_script('user-new'); |
| 194 | wp_enqueue_script('jquery-ui-autocomplete'); |
181 | 195 | |
182 | 196 | require_once ('admin-header.php'); |
183 | 197 | |
… |
… |
if ( is_multisite() ) { |
265 | 279 | <table class="form-table"> |
266 | 280 | <tr class="form-field form-required"> |
267 | 281 | <th scope="row"><label for="adduser-email"><?php echo $label; ?></label></th> |
268 | | <td><input name="email" type="text" id="adduser-email" value="" /></td> |
| 282 | <td><input name="email" type="text" id="adduser-email" value="" /><ul id="add-to-blog-users"></ul></td> |
269 | 283 | </tr> |
270 | 284 | <tr class="form-field"> |
271 | 285 | <th scope="row"><label for="adduser-role"><?php _e('Role'); ?></label></th> |