Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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