From fdd6a154ada017f7c8478f0f9b531eecb030a524 Mon Sep 17 00:00:00 2001 From: jorge-vitrubio Date: Wed, 30 Mar 2022 17:39:03 +0200 Subject: [PATCH] function to delete capabilities in wp db --- includes/arcHIVE-delete-capabilities.php | 59 ++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 includes/arcHIVE-delete-capabilities.php diff --git a/includes/arcHIVE-delete-capabilities.php b/includes/arcHIVE-delete-capabilities.php new file mode 100644 index 0000000..292be3b --- /dev/null +++ b/includes/arcHIVE-delete-capabilities.php @@ -0,0 +1,59 @@ + + */ + +// Function to delete capabilities +// Based on http://chrisburbridge.com/delete-unwanted-wordpress-custom-capabilities/ +function clean_unwanted_caps() { + global $wp_roles; + $delete_caps = array( + 'read_archive_resource', + 'publish_archive_resources', + 'edit_archive_resources', + 'edit_archive_published_resources', + 'edit_other_archive_resources', + 'delete_archive_resources', + 'delete_archive_published_resources', + 'delete_archive_others_resources', + 'delete_archive_private_resources', + 'upload_media_files', + 'manage_archive_resources_types', + 'archive_read_resource', + 'archive_publish_resources', + 'archive_edit_resources', + 'archive_edit_published_resources', + 'archive_edit_other_resources', + 'archive_delete_resources', + 'archive_delete_published_resources', + 'archive_delete_others_resources', + 'archive_delete_private_resources', + 'archive_upload_media_files', + 'archive_manage_resources_types', + 'archive_manage_resources_types' + ); + foreach ($delete_caps as $cap) { + foreach (array_keys($wp_roles->roles) as $role) { + $wp_roles->remove_cap($role, $cap); + } + } +} +add_action( 'admin_init', 'clean_unwanted_caps' ); +// register_activation_hook( __FILE__, 'archive_wpplugin_add_roles_on_plugin_activation' );