0

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

1

You can use jQuery to disable the display name select.

function disable_display_name() {
    global $pagenow;
    if ( $pagenow == 'profile.php' ) {
    ?>
        <script>
            jQuery( document ).ready(function() {
                jQuery('#display_name').prop('disabled', 'disabled');
            });
        </script>
    <?php
    }
}
add_action( 'admin_head', 'disable_display_name', 15 );
| improve this answer | |
  • 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. – Luke Stevenson May 10 '19 at 5:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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