wordpress - 对 w3-total-cache 上的特定角色禁用 "Purge from Page Cache"

标签 wordpress caching plugins

使用插件 w3-total 缓存,在 wordpress-posts 的概述中,可以为每个帖子“从页面缓存中清除”。

此功能也适用于“作者”角色的用户。如果这只能在他们自己的帖子上实现,那就没什么好担心的。但作为“作者”,您也可以在其他用户的帖子上执行此操作。

那么,有没有办法配置 w3tc 不允许特定用户组这样做?

最佳答案

这会删除所有角色的链接,将其放入functions.php

function remove_purge_from_page_cache_link($actions, $post){
  unset($actions['pgcache_purge']);

  return $actions;
}

add_filter('post_row_actions', 'remove_purge_from_page_cache_link',1000,2);
add_filter('page_row_actions', 'remove_purge_from_page_cache_link',1000,2);

要使其仅针对作者删除,您需要使用类似的内容

if (!current_user_can('publish_posts')) {
    unset($actions['pgcache_purge']);
}

您可以调整逻辑以定位您想要的用户组。

关于wordpress - 对 w3-total-cache 上的特定角色禁用 "Purge from Page Cache",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8848699/

相关文章:

php - 如何将变量传递给 Action Hook 函数?

php - 自定义模板页面标题未在 WordPress 中加载 style.css

caching - 如何使用 Elixir ets 创建复杂查询

java - Eclipse 扩展和声明式服务

plugins - 编写屏幕共享插件/驱动程序

php - 如何在数据库中保存为文本类型时比较日期

javascript - 如何在Wordpress的一篇文章中插入或嵌入多个YouTube视频?

css - Drupal 8 缓存 css 和 js

python - 缓存 Python 脚本返回的 mysql 查询

jQuery 插件创建和面向公众的方法