uzed_creative
uzed_creative

Reputation: 65

disable "Purge from Page Cache" for specific roles on w3-total-cache

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 .

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

Upvotes: 3

Views: 2358

Answers (1)

Adam Pope
Adam Pope

Reputation: 3274

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.

Upvotes: 0

Related Questions