What would I have to do to prevent users changing their display_name?

1 Answer 1


You can use jQuery to disable the display name select.

function disable_display_name() {
    global $pagenow;
    if ( $pagenow == 'profile.php' ) {
            jQuery( document ).ready(function() {
                jQuery('#display_name').prop('disabled', 'disabled');
add_action( 'admin_head', 'disable_display_name', 15 );
  • 1
    NOTE: This solution only disables the form field. Should a User have any basic knowledge of HTML and/or modern web browsers, this can be quickly circumvented. May 10, 2019 at 5:20
  • Sorry but it is not a good solution, I just disable Javascript to change it Nov 18, 2021 at 16:00
  • @LaurenceCope There's no filter available to modify the HTML of the dropdown. It's either JavaScript or CSS. You'll have to restrict the users from accessing backend if you don't trust them.
    – Abhik
    Nov 19, 2021 at 7:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.