如果不复制整个用户界面,似乎就不容易进行覆盖。因此,最快的解决方案可能是通过JavaScript取消选中复选框:
add_action(\'admin_footer\', \'uncheck_send_user_notification\');
function uncheck_send_user_notification() {
$currentScreen = get_current_screen();
if (\'user\' === $currentScreen->id) {
echo \'<script type="text/javascript">document.getElementById("send_user_notification").checked = false;</script>\';
}
}
脚本仅注入到
user-new.php
页码(参见
$currentScreen->id
), 然后选中复选框(请参见
document.getElementById
) 并将选中的设置为
false
.
更新:不是检查函数中的当前屏幕,而是admin_footer-{$hook_suffix}
仅在特定管理页面上运行的操作:
add_action(\'admin_footer-user-new.php\', \'uncheck_send_user_notification\');
function uncheck_send_user_notification() {
echo \'<script type="text/javascript">document.getElementById("send_user_notification").checked = false;</script>\';
}