Skip to content

Instantly share code, notes, and snippets.

@joshbetz
Created April 30, 2017 01:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshbetz/0cc88833bda6f700ae4668148c06fec5 to your computer and use it in GitHub Desktop.
Save joshbetz/0cc88833bda6f700ae4668148c06fec5 to your computer and use it in GitHub Desktop.
Don't allow users to delete or edit their activity
<?php
// https://wordpress.org/plugins/wp-user-activity/
/**
* Don't allow users to delete or edit their activity.
*
* If the site has been hacked, make it hard for attackers
* to cover their steps.
*/
add_filter( 'wp_user_activity_meta_caps', function( $caps, $cap ) {
switch ( $cap ) {
// Editing
case 'publish_activities':
case 'edit_others_activities':
case 'edit_activity':
// Deleting
case 'delete_activity':
case 'delete_activities':
case 'delete_others_activities':
return array( 'do_not_allow' );
case 'edit_activities': // Needed to list activities
default:
return $caps;
}
}, 0, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment