SO网友:Frank P. Walentynowicz
将以下内容添加到functions.php
当前主题的(首选子主题!):
CSS solution:
function no_email_changes_in_profile() {
$screen = get_current_screen();
if (\'profile\' == $screen->base && !current_user_can(\'manage_options\')) {
echo \'<style>
input#email {
pointer-events: none;
}
</style>\';
}
}
add_action(\'admin_head\', \'no_email_changes_in_profile\');
jQuery solution:
function no_email_changes_in_profile() {
$screen = get_current_screen();
if (\'profile\' == $screen->base && !current_user_can(\'manage_options\')) {
echo "<script>
jQuery(document).ready(function($) {
$(\'#email\').prop(\'readonly\', true);
});
</script>";
}
}
add_action(\'admin_head\', \'no_email_changes_in_profile\');
这将禁用除管理员以外的所有用户在配置文件管理页面上编辑“电子邮件”字段。