Make WordPress Core

Ticket #27606: 27606.patch

File 27606.patch, 4.6 KB (added by boonebgorges, 11 years ago)
  • src/wp-admin/network/user-new.php

    diff --git src/wp-admin/network/user-new.php src/wp-admin/network/user-new.php
    index 29fd63d..0078943 100644
    if ( ! empty( $messages ) ) { 
    7676                echo '<div id="message" class="updated"><p>' . $msg . '</p></div>';
    7777}
    7878
     79// Pre-fill values in case of a previous failed submission
     80foreach ( array( 'username', 'email' ) as $post_key ) {
     81        $$post_key = isset( $_POST['user'][ $post_key ] ) ? stripslashes( $_POST['user'][ $post_key ] ) : '';
     82}
     83
    7984if ( isset( $add_user_errors ) && is_wp_error( $add_user_errors ) ) { ?>
    8085        <div class="error">
    8186                <?php
    if ( isset( $add_user_errors ) && is_wp_error( $add_user_errors ) ) { ?> 
    8893        <table class="form-table">
    8994                <tr class="form-field form-required">
    9095                        <th scope="row"><?php _e( 'Username' ) ?></th>
    91                         <td><input type="text" class="regular-text" name="user[username]" /></td>
     96                        <td><input type="text" class="regular-text" name="user[username]" value="<?php echo esc_attr( $username ) ?>" /></td>
    9297                </tr>
    9398                <tr class="form-field form-required">
    9499                        <th scope="row"><?php _e( 'Email' ) ?></th>
    95                         <td><input type="text" class="regular-text" name="user[email]" /></td>
     100                        <td><input type="text" class="regular-text" name="user[email]" value="<?php echo esc_attr( $email ) ?>" /></td>
    96101                </tr>
    97102                <tr class="form-field">
    98103                        <td colspan="2"><?php _e( 'Username and password will be mailed to the above email address.' ) ?></td>
  • src/wp-admin/user-new.php

    diff --git src/wp-admin/user-new.php src/wp-admin/user-new.php
    index b5c9c0b..6219188 100644
    if ( isset($_REQUEST['action']) && 'adduser' == $_REQUEST['action'] ) { 
    4141        check_admin_referer( 'add-user', '_wpnonce_add-user' );
    4242
    4343        $user_details = null;
     44        $redirect_args = array();
     45        foreach ( array( 'email', 'role', 'noconfirmation' ) as $redirect_arg ) {
     46                if ( isset( $_REQUEST[ $redirect_arg ] ) ) {
     47                        $redirect_args[ $redirect_arg ] = $_REQUEST[ $redirect_arg ];
     48                }
     49        }
     50
    4451        if ( false !== strpos($_REQUEST[ 'email' ], '@') ) {
    4552                $user_details = get_user_by('email', $_REQUEST[ 'email' ]);
    4653        } else {
    4754                if ( is_super_admin() ) {
    4855                        $user_details = get_user_by('login', $_REQUEST[ 'email' ]);
    4956                } else {
    50                         wp_redirect( add_query_arg( array('update' => 'enter_email'), 'user-new.php' ) );
     57                        $redirect_args['update'] = 'enter_email';
     58                        wp_redirect( add_query_arg( $redirect_args, 'user-new.php' ) );
    5159                        die();
    5260                }
    5361        }
    5462
    5563        if ( !$user_details ) {
    56                 wp_redirect( add_query_arg( array('update' => 'does_not_exist'), 'user-new.php' ) );
     64                $redirect_args['update'] = 'does_not_exist';
     65                wp_redirect( add_query_arg( $redirect_args, 'user-new.php' ) );
    5766                die();
    5867        }
    5968
    if ( is_multisite() ) { 
    290299<input name="action" type="hidden" value="adduser" />
    291300<?php wp_nonce_field( 'add-user', '_wpnonce_add-user' ) ?>
    292301
     302<?php
     303// Pre-fill values in case of a previous failed submission
     304foreach ( array( 'email' => 'adduser_email', 'role' => 'adduser_role', 'noconfirmation' => 'adduser_noconfirmation' ) as $adduser_key => $adduser_var ) {
     305        $$adduser_var = isset( $_GET[ $adduser_key ] ) ? urldecode( $_GET[ $adduser_key ] ) : '';
     306}
     307?>
     308
    293309<table class="form-table">
    294310        <tr class="form-field form-required">
    295311                <th scope="row"><label for="adduser-email"><?php echo $label; ?></label></th>
    296                 <td><input name="email" type="text" id="adduser-email" class="wp-suggest-user" value="" /></td>
     312                <td><input name="email" type="text" id="adduser-email" class="wp-suggest-user" value="<?php echo esc_attr( $adduser_email ) ?>" /></td>
    297313        </tr>
    298314        <tr class="form-field">
    299315                <th scope="row"><label for="adduser-role"><?php _e('Role'); ?></label></th>
     316                <?php $adduser_role_default = ! empty( $adduser_role ) ? $adduser_role : get_option( 'default_role' ); ?>
    300317                <td><select name="role" id="adduser-role">
    301                         <?php wp_dropdown_roles( get_option('default_role') ); ?>
     318                        <?php wp_dropdown_roles( $adduser_role_default ); ?>
    302319                        </select>
    303320                </td>
    304321        </tr>
    305322<?php if ( is_super_admin() ) { ?>
    306323        <tr>
    307324                <th scope="row"><label for="adduser-noconfirmation"><?php _e('Skip Confirmation Email') ?></label></th>
    308                 <td><label for="adduser-noconfirmation"><input type="checkbox" name="noconfirmation" id="adduser-noconfirmation" value="1" /> <?php _e( 'Add the user without sending them a confirmation email.' ); ?></label></td>
     325                <td><label for="adduser-noconfirmation"><input type="checkbox" name="noconfirmation" id="adduser-noconfirmation" value="1" <?php checked( $adduser_noconfirmation, '1' ) ?>/> <?php _e( 'Add the user without sending them a confirmation email.' ); ?></label></td>
    309326        </tr>
    310327<?php } ?>
    311328</table>