~canonical-sysadmins/wordpress/4.2.4

« back to all changes in this revision

Viewing changes to wp-admin/user-new.php

  • Committer: Nick Moffitt
  • Date: 2015-01-15 11:05:37 UTC
  • mfrom: (1.1.1 wp4-upstream)
  • Revision ID: nick.moffitt@canonical.com-20150115110537-8bp1y42eyg0jsa7c
Tags: 4.1
MergeĀ upstreamĀ versionĀ 4.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
if ( is_multisite() ) {
13
13
        if ( ! current_user_can( 'create_users' ) && ! current_user_can( 'promote_users' ) )
14
 
                wp_die( __( 'Cheatin’ uh?' ) );
 
14
                wp_die( __( 'Cheatin’ uh?' ), 403 );
15
15
} elseif ( ! current_user_can( 'create_users' ) ) {
16
 
        wp_die( __( 'Cheatin’ uh?' ) );
 
16
        wp_die( __( 'Cheatin’ uh?' ), 403 );
17
17
}
18
18
 
19
19
if ( is_multisite() ) {
31
31
%%s' ), get_bloginfo( 'name' ), home_url(), wp_specialchars_decode( translate_user_role( $role['name'] ) ) );
32
32
        }
33
33
        add_filter( 'wpmu_signup_user_notification_email', 'admin_created_user_email' );
34
 
 
35
 
        function admin_created_user_subject( $text ) {
36
 
                return sprintf( __( '[%s] Your site invite' ), get_bloginfo( 'name' ) );
37
 
        }
38
34
}
39
35
 
40
36
if ( isset($_REQUEST['action']) && 'adduser' == $_REQUEST['action'] ) {
41
37
        check_admin_referer( 'add-user', '_wpnonce_add-user' );
42
38
 
43
39
        $user_details = null;
44
 
        if ( false !== strpos($_REQUEST[ 'email' ], '@') ) {
45
 
                $user_details = get_user_by('email', $_REQUEST[ 'email' ]);
 
40
        $user_email = wp_unslash( $_REQUEST['email'] );
 
41
        if ( false !== strpos( $user_email, '@' ) ) {
 
42
                $user_details = get_user_by( 'email', $user_email );
46
43
        } else {
47
44
                if ( is_super_admin() ) {
48
 
                        $user_details = get_user_by('login', $_REQUEST[ 'email' ]);
 
45
                        $user_details = get_user_by( 'login', $user_email );
49
46
                } else {
50
47
                        wp_redirect( add_query_arg( array('update' => 'enter_email'), 'user-new.php' ) );
51
48
                        die();
58
55
        }
59
56
 
60
57
        if ( ! current_user_can('promote_user', $user_details->ID) )
61
 
                wp_die(__('Cheatin’ uh?'));
 
58
                wp_die( __( 'Cheatin’ uh?' ), 403 );
62
59
 
63
60
        // Adding an existing user to this blog
64
61
        $new_user_email = $user_details->user_email;
95
92
        check_admin_referer( 'create-user', '_wpnonce_create-user' );
96
93
 
97
94
        if ( ! current_user_can('create_users') )
98
 
                wp_die(__('Cheatin’ uh?'));
 
95
                wp_die( __( 'Cheatin’ uh?' ), 403 );
99
96
 
100
97
        if ( ! is_multisite() ) {
101
98
                $user_id = edit_user();
112
109
                }
113
110
        } else {
114
111
                // Adding a new user to this site
115
 
                $user_details = wpmu_validate_user_signup( $_REQUEST[ 'user_login' ], $_REQUEST[ 'email' ] );
 
112
                $new_user_email = wp_unslash( $_REQUEST['email'] );
 
113
                $user_details = wpmu_validate_user_signup( $_REQUEST['user_login'], $new_user_email );
116
114
                if ( is_wp_error( $user_details[ 'errors' ] ) && !empty( $user_details[ 'errors' ]->errors ) ) {
117
115
                        $add_user_errors = $user_details[ 'errors' ];
118
116
                } else {
126
124
                        $new_user_login = apply_filters( 'pre_user_login', sanitize_user( wp_unslash( $_REQUEST['user_login'] ), true ) );
127
125
                        if ( isset( $_POST[ 'noconfirmation' ] ) && is_super_admin() ) {
128
126
                                add_filter( 'wpmu_signup_user_notification', '__return_false' ); // Disable confirmation email
 
127
                                add_filter( 'wpmu_welcome_user_notification', '__return_false' ); // Disable welcome email
129
128
                        }
130
 
                        wpmu_signup_user( $new_user_login, $_REQUEST[ 'email' ], array( 'add_to_blog' => $wpdb->blogid, 'new_role' => $_REQUEST[ 'role' ] ) );
 
129
                        wpmu_signup_user( $new_user_login, $new_user_email, array( 'add_to_blog' => $wpdb->blogid, 'new_role' => $_REQUEST['role'] ) );
131
130
                        if ( isset( $_POST[ 'noconfirmation' ] ) && is_super_admin() ) {
132
 
                                $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' ] ) );
 
131
                                $key = $wpdb->get_var( $wpdb->prepare( "SELECT activation_key FROM {$wpdb->signups} WHERE user_login = %s AND user_email = %s", $new_user_login, $new_user_email ) );
133
132
                                wpmu_activate_signup( $key );
134
133
                                $redirect = add_query_arg( array('update' => 'addnoconfirmation'), 'user-new.php' );
135
134
                        } else {
281
280
                $type  = 'text';
282
281
        }
283
282
?>
284
 
<?php
285
 
/**
286
 
 * Fires inside the adduser form tag.
287
 
 *
288
 
 * @since 3.0.0
289
 
 */
290
 
?>
291
 
<form action="" method="post" name="adduser" id="adduser" class="validate" novalidate="novalidate"<?php do_action( 'user_new_form_tag' );?>>
 
283
<form action="" method="post" name="adduser" id="adduser" class="validate" novalidate="novalidate"<?php
 
284
        /**
 
285
         * Fires inside the adduser form tag.
 
286
         *
 
287
         * @since 3.0.0
 
288
         */
 
289
        do_action( 'user_new_form_tag' );
 
290
?>>
292
291
<input name="action" type="hidden" value="adduser" />
293
292
<?php wp_nonce_field( 'add-user', '_wpnonce_add-user' ) ?>
294
293
 
335
334
                echo '<h3 id="create-new-user">' . __( 'Add New User' ) . '</h3>';
336
335
?>
337
336
<p><?php _e('Create a brand new user and add them to this site.'); ?></p>
338
 
<?php /** This action is documented in wp-admin/user-new.php */ ?>
339
 
<form action="" method="post" name="createuser" id="createuser" class="validate" novalidate="novalidate"<?php do_action( 'user_new_form_tag' );?>>
 
337
<form action="" method="post" name="createuser" id="createuser" class="validate" novalidate="novalidate"<?php
 
338
        /** This action is documented in wp-admin/user-new.php */
 
339
        do_action( 'user_new_form_tag' );
 
340
?>>
340
341
<input name="action" type="hidden" value="createuser" />
341
342
<?php wp_nonce_field( 'create-user', '_wpnonce_create-user' ); ?>
342
343
<?php
397
398
                <input name="pass2" type="password" id="pass2" autocomplete="off" />
398
399
                <br />
399
400
                <div id="pass-strength-result"><?php _e('Strength indicator'); ?></div>
400
 
                <p class="description indicator-hint"><?php _e('Hint: The password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers, and symbols like ! " ? $ % ^ &amp; ).'); ?></p>
 
401
                <p class="description indicator-hint"><?php echo wp_get_password_hint(); ?></p>
401
402
                </td>
402
403
        </tr>
403
404
        <tr>