为了解决第三方插件的愚蠢问题,我不得不为用户级用户提供一些我不希望他们实际拥有的编辑功能。 (这并不能让他们访问编辑链接,但如果他们聪明,他们可以直接访问编辑URL。)由于我的网站只有订阅用户和管理用户,我可以通过简单地修改wp-admin中的功能检查来解决问题/post.php,要求用户不具有附加功能,比如:如何永久修改WordPress的'wp-admin/post.php?
if (! current_user_can('edit_post', $post_id))
wp_die(__('Sorry, you are not allowed to edit this item.'));
变为:
if (! current_user_can('edit_post', $post_id) OR ! current_user_can('edit_pages'))
wp_die(__('Sorry, you are not allowed to edit this item.'));
这工作完全,但我知道它会被覆盖,并且需要每次更新Wordpress时都要重新做。有没有办法通过过滤器或类似方式以更持久的方式应用此修复程序?