Created
June 19, 2016 17:02
-
-
Save sushyant/f7e3a962a0809ef652eeb702920b15fa to your computer and use it in GitHub Desktop.
Add this to your theme’s functions.php file. Read more: https://sushyant.com/wordpress/prevent-users-from-changing-email-address
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DisableEmailChange | |
{ | |
function __construct() | |
{ | |
add_action('admin_footer', array($this, 'disable_userprofile_fields')); | |
} | |
function disable_userprofile_fields() | |
{ | |
global $pagenow; | |
if ($pagenow == 'profile.php' && !current_user_can( 'manage_options' )) { | |
?> | |
<script> | |
jQuery(document).ready(function ($) { | |
if ($('input[name=email]').length) { | |
$('input[name=email]').attr("disabled", "disabled"); | |
} | |
}); | |
</script> | |
<?php | |
} | |
} | |
} // End Class | |
$DisableEmailChange = new DisableEmailChange(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment