WordPress.org

Make WordPress Core

Ticket #33793: 33792.diff

File 33792.diff, 1.7 KB (added by utkarshpatel, 4 years ago)

Added html max-length 50 for user_login and also added check in backed for length.

  • wp-admin/includes/user.php

    diff --git wp-admin/includes/user.php wp-admin/includes/user.php
    index 729ec18..ecde547 100644
    function edit_user( $user_id = 0 ) { 
    104104
    105105        $errors = new WP_Error();
    106106
    107         /* checking that username has been typed */
     107        /* checking that username has been typed and user_login is less than 50 characters */
    108108        if ( $user->user_login == '' )
    109109                $errors->add( 'user_login', __( '<strong>ERROR</strong>: Please enter a username.' ) );
     110        elseif ( strlen( $user->user_login ) >= 50 )
     111                $errors->add( 'user_login', __( '<strong>ERROR</strong>: Please enter a username less than 50 characters.' ) );
    110112
    111113        /* checking the password has been typed twice */
    112114        /**
  • wp-admin/user-new.php

    diff --git wp-admin/user-new.php wp-admin/user-new.php
    index 2f6c5bf..8e71d4a 100644
    $new_user_ignore_pass = $creating && isset( $_POST['noconfirmation'] ) ? wp_unsl 
    393393<table class="form-table">
    394394        <tr class="form-field form-required">
    395395                <th scope="row"><label for="user_login"><?php _e('Username'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th>
    396                 <td><input name="user_login" type="text" id="user_login" value="<?php echo esc_attr( $new_user_login ); ?>" aria-required="true" autocapitalize="none" autocorrect="off" /></td>
     396                <td><input name="user_login" type="text" id="user_login" value="<?php echo esc_attr( $new_user_login ); ?>" aria-required="true" autocapitalize="none" autocorrect="off" maxlength="50" /></td>
    397397        </tr>
    398398        <tr class="form-field form-required">
    399399                <th scope="row"><label for="email"><?php _e('Email'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th>