Remove Option in user profile to change public displayname
-
I searched everywhere for a fix to this problem and saw that a few others had issues finding the answer as well. I thought I would post what I came up with as a solution. It was a simple fix.
Here is what this modification does:
Do you want to make sure nobody can change their display name by manipulating their firstname and the “Display username publicy as:” feature?This is useful if you run a chat application on your site that uses the wordpress/buddypress user system to sign your chat users on.
For example, by default a user can make their username “Blueuser” – If Blueuser wants to impersonate an admin named “RedAdmin” all that blueuser needs to do is change his first name in his profile to “RedAdmin” and then select “Display Username Publicy as: RedAdmin” and walla! Blueuser now appears in chat as RedAdmin
Here is how to fix this problem.
Locate the following file in your wordpress installation:
/wp-admin/user-edit.phpFirst, make a back up copy of this file adding a ~ before the name ( ~user-edit.php) just in case you mess things up.
Open the file user-edit.php
Find and delete the following lines of code:
<tr> <th><label for="display_name"><?php _e('Display name publicly as') ?></label></th> <td> <select name="display_name" id="display_name"> <?php $public_display = array(); $public_display['display_nickname'] = $profileuser->nickname; $public_display['display_username'] = $profileuser->user_login; if ( !empty($profileuser->first_name) ) $public_display['display_firstname'] = $profileuser->first_name; if ( !empty($profileuser->last_name) ) $public_display['display_lastname'] = $profileuser->last_name; if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) { $public_display['display_firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name; $public_display['display_lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name; } if ( !in_array( $profileuser->display_name, $public_display ) ) // Only add this if it isn't duplicated elsewhere $public_display = array( 'display_displayname' => $profileuser->display_name ) + $public_display; $public_display = array_map( 'trim', $public_display ); $public_display = array_unique( $public_display ); foreach ( $public_display as $id => $item ) { ?> <option <?php selected( $profileuser->display_name, $item ); ?>><?php echo $item; ?></option> <?php } ?> </select> </td> </tr>
You have now removed the ability for the user to select their display name. By default, usernames will now only display. First name will not be an option anymore.
- The topic ‘Remove Option in user profile to change public displayname’ is closed to new replies.