Disable WordPress Nickname

Place the following code in your function.php file. (Appearance > Editor > Theme Functions – functions.php)

// remove nickname
function prefix_hide_personal_options() {
        if (current_user_can('manage_options')) return false;
?>
<script type="text/javascript">
  jQuery(document).ready(function( $ ){
    $("#nickname,#display_name").parent().parent().remove();
  });
</script>
<?php
}
if (is_admin()) add_action('personal_options', 'prefix_hide_personal_options');

Source: https://premium.wpmudev.org/blog/how-to-restrict-usernames-and-disable-nicknames-in-wordpress/

Leave a Reply

Your email address will not be published. Required fields are marked *