• I’m looking to modify the new user page in the dashboard so that the username is automatically filled using the first letter of the first name and the full last name. I was thinking about modifying lines 321 and 322 that contain the code below to pull the string from the first name and last name fields. Does anyone have any easier ideas or recommendations on the implementation of this?

    Thanks

    <th scope="row"><label for="user_login"><?php _e('Username'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th>
    		<td><input name="user_login" type="text" id="user_login" value="<?php echo esc_attr($new_user_login); ?>" aria-required="true" /></td>
Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    First of all, please do not even contemplate altering the code in core files. While it may be tempting, it will eventually lead to trouble. Just don’t do it.

    Second, what version WordPress are you using? That code occurs at line 359 in the current version. Please update ASAP!

    Third, when the page is sent to the browser, the fields are typically blank, there’s no data to populate the username field with yet. And if there is data, the username has already been assigned. When the names are eventually inserted, it’s too late for PHP to affect anything. Such behavior needs to be done with javascript.

    If you do develop a javascript solution, consider how it works carefully. If someone were to select a username before entering real names, it would be rude to overwrite that with the first initial last name scheme. Unless you wish to actively enforce such a scheme. In that case make the username field inactive so no one can attempt a different name. Perhaps add a little note that the field auto-populates. Feel free to ignore this last paragraph. None of my business really, but I couldn’t resist a suggestion or two 🙂

Viewing 1 replies (of 1 total)

The topic ‘Modify New User Page’ is closed to new replies.