禁用“从页面缓存清除";对于W3-Total-Cache上的特定角色 [英] disable "Purge from Page Cache" for specific roles on w3-total-cache

查看:66
本文介绍了禁用“从页面缓存清除";对于W3-Total-Cache上的特定角色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

with the plugin w3-total cache, in the overview of wordpress-posts there is the ability to "Purge from Page Cache" for each post.

该功能也可用于角色作者"的用户.如果仅在自己的帖子上可以这样做,则无需担心.但作为作者",您也可以在其他用户的帖子上进行此操作.

this function is also available for users of the role "author". this is nothing to worry about if this were possible only on their own posts. but as an "author" you can do this also on other users posts .

那么,有没有一种方法可以将w3tc配置为不允许特定的用户组使用它?

so, is there a way to configure w3tc to not allow this for specific user-groups?

推荐答案

这将删除所有角色的链接,并将其放在functions.php中.

This removes the link for all roles, put it in 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);

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

To make it only remove for authors you'll want to use something like this

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

您可以调整逻辑以定位所需的用户组.

You can tweak the logic to target the user group(s) you want.

这篇关于禁用“从页面缓存清除";对于W3-Total-Cache上的特定角色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆