我找到了一个代码来阻止某些用户角色的WordPress更新:
add_action( \'init\', function () {
if ( ! current_user_can( \'administrator\' ) ) {
add_filter( \'pre_site_transient_update_core\', \'disable_updates\' ); // Disable WordPress core updates
add_filter( \'pre_site_transient_update_plugins\', \'disable_updates\' ); // Disable WordPress plugin updates
add_filter( \'pre_site_transient_update_themes\', \'disable_updates\' ); // Disable WordPress theme updates
}
} );
那么只允许一个用户更新呢?
最合适的回答,由SO网友:twelvell 整理而成
SOLUTION:
我们将此代码粘贴到函数中。php:
function createit_hide_upd_for_other_adm_users() {
$current_user = wp_get_current_user();
if ( 777 != $current_user->ID ) { //change the user ID
add_filter( \'pre_site_transient_update_core\', \'disable_updates\' );
add_filter( \'pre_site_transient_update_plugins\', \'disable_updates\' );
add_filter( \'pre_site_transient_update_themes\', \'disable_updates\' );
} else {
}
}
add_action( \'init\', \'createit_hide_upd_for_other_adm_users\' );
你只需要找到正确的
WordPress user ID 把它放在777的位置,就是这样!