将此添加到您的函数中。主题文件夹中的php:
function restrict_post_deletion($post_ID){
$user = get_current_user_id();
$restricted_users = array(21,25,54,2,19);
$restricted_pages = array(2,21,52,64);
if(in_array($user, $restricted_users) && in_array($post_ID, $restricted_pages)){
echo "You are not authorized to delete this page.";
exit;
}
}
add_action(\'wp_trash_post\', \'restrict_post_deletion\', 10, 1);
add_action(\'wp_delete_post\', \'restrict_post_deletion\', 10, 1);
摘自
here 并更新至最新WP版本。