WordPress.org

Make WordPress Core

Ticket #15456: user-new-form-updates.diff

File user-new-form-updates.diff, 4.4 KB (added by wpdavis, 5 years ago)
  • wp-admin/user-new.php

     
    222222                $label = __('E-mail or Username'); 
    223223        } 
    224224?> 
    225 <form action="#add-existing-user" method="post" name="adduser" id="adduser" class="add:users: validate"<?php do_action('user_new_form_tag');?>> 
     225<form action="" method="post" name="adduser" id="adduser" class="add:users: validate"<?php do_action('user_new_form_tag');?>> 
    226226<input name="action" type="hidden" id="action" value="adduser" /> 
    227227<?php wp_nonce_field('add-user') ?> 
     228<?php 
     229// Load up the passed data, else set to a default. 
     230foreach ( array('email' => 'email', 'role' => 'role') as $post_field => $var ) { 
     231        $var = "existing_user_$var"; 
     232                $$var = false; 
     233} 
     234$existing_user_ignore_pass = ''; 
     235?> 
     236 
    228237<table class="form-table"> 
    229238        <tr class="form-field form-required"> 
    230239                <th scope="row"><label for="email"><?php echo $label; ?></label></th> 
    231                 <td><input name="email" type="text" id="email" value="<?php echo esc_attr($new_user_email); ?>" /></td> 
     240                <td><input name="email" type="text" id="email" value="<?php echo esc_attr($existing_user_email); ?>" /></td> 
    232241        </tr> 
    233242        <tr class="form-field"> 
    234243                <th scope="row"><label for="role"><?php _e('Role'); ?></label></th> 
    235244                <td><select name="role" id="role"> 
    236245                        <?php 
    237                         if ( !$new_user_role ) 
    238                                 $new_user_role = !empty($current_role) ? $current_role : get_option('default_role'); 
    239                         wp_dropdown_roles($new_user_role); 
     246                        if ( !$existing_user_role ) 
     247                                $existing_user_role = !empty($current_role) ? $current_role : get_option('default_role'); 
     248                        wp_dropdown_roles($existing_user_role); 
    240249                        ?> 
    241250                        </select> 
    242251                </td> 
     
    244253<?php if ( is_super_admin() ) { ?> 
    245254        <tr> 
    246255                <th scope="row"><label for="noconfirmation"><?php _e('Skip Confirmation Email') ?></label></th> 
    247                 <td><label for="noconfirmation"><input type="checkbox" name="noconfirmation" id="noconfirmation" value="1" /> <?php _e( 'Add the user without sending them a confirmation email.' ); ?></label></td> 
     256                <td><label for="noconfirmation"><input type="checkbox" name="noconfirmation" id="noconfirmation" value="1"  <?php checked($existing_user_ignore_pass, true); ?> /> <?php _e( 'Add the user without sending them a confirmation email.' ); ?></label></td> 
    248257        </tr> 
    249258<?php } ?> 
    250259</table> 
     
    258267                echo '<h3 id="create-new-user">' . __('Create New User') . '</h3>'; 
    259268?> 
    260269<p><?php _e('Create a brand new user and add it to this site.'); ?></p> 
    261 <form action="#create-new-user" method="post" name="createuser" id="adduser" class="add:users: validate"<?php do_action('user_new_form_tag');?>> 
     270<form action="" method="post" name="createuser" id="adduser" class="add:users: validate"<?php do_action('user_new_form_tag');?>> 
    262271<input name="action" type="hidden" id="action" value="createuser" /> 
    263272<?php wp_nonce_field('create-user') ?> 
    264273<?php 
     
    266275foreach ( array('user_login' => 'login', 'first_name' => 'firstname', 'last_name' => 'lastname', 
    267276                                'email' => 'email', 'url' => 'uri', 'role' => 'role') as $post_field => $var ) { 
    268277        $var = "new_user_$var"; 
    269         if ( ! isset($$var) ) 
    270                 $$var = isset($_POST[$post_field]) ? stripslashes($_POST[$post_field]) : ''; 
     278        if(isset($_POST['createuser'])) { 
     279                if ( ! isset($$var) ) 
     280                        $$var = isset($_POST[$post_field]) ? stripslashes($_POST[$post_field]) : ''; 
     281        } else { 
     282                $$var = ''; 
     283        } 
    271284} 
    272 $new_user_send_password = !$_POST || isset($_POST['send_password']); 
     285if(isset($_POST['createuser'])) { 
     286        $new_user_send_password = !$_POST || isset($_POST['send_password']); 
     287        $new_user_ignore_pass = !$_POST || isset($_POST['noconfirmation']); 
     288} else { 
     289        $new_user_send_password = ''; 
     290        $new_user_ignore_pass = ''; 
     291} 
    273292?> 
    274293<table class="form-table"> 
    275294        <tr class="form-field form-required"> 
     
    324343        <?php if ( is_multisite() && is_super_admin() ) { ?> 
    325344        <tr> 
    326345                <th scope="row"><label for="noconfirmation"><?php _e('Skip Confirmation Email') ?></label></th> 
    327                 <td><label for="noconfirmation"><input type="checkbox" name="noconfirmation" id="noconfirmation" value="1" /> <?php _e( 'Add the user without sending them a confirmation email.' ); ?></label></td> 
     346                <td><label for="noconfirmation"><input type="checkbox" name="noconfirmation" id="noconfirmation" value="1"  <?php checked($new_user_ignore_pass, true); ?> /> <?php _e( 'Add the user without sending them a confirmation email.' ); ?></label></td> 
    328347        </tr> 
    329348        <?php } ?> 
    330349</table>