Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save adczk/97bcd754a7ac3583d809dbd119db0c76 to your computer and use it in GitHub Desktop.
Save adczk/97bcd754a7ac3583d809dbd119db0c76 to your computer and use it in GitHub Desktop.
Forminator - hide and disallow bulk delete entry actions and delete/resend buttons for subscriber roles
<?php
/**
* Plugin Name: Forminator - block entry delete action for subscribers
* Plugin URI: https://gist.github.com/adczk
* Description: Hides and disallows delte entry options for subscribers; hides other buttons in single entry footer too
* Author: adczk
*
* Author URI: https://gist.github.com/adczk
* License: GPLv2 or later
*
* Use as MU plugin;
*
* Tested with Forminator 1.34.0
*
* you can replace "subscirber" role in code with any other role
* role has to be first given permission to access submissions via the Forminator permission settings
*
*/
// hide bulk options and delete button
add_action( 'admin_footer', 'wpmu_block_forminator_delete_entry_css' );
function wpmu_block_forminator_delete_entry_css() {
$user = wp_get_current_user();
if ( in_array( 'subscriber', (array) $user->roles ) ) {
?>
<style>
.wpmudev-forminator-forminator-entries .sui-search-left *,
.wpmudev-forminator-forminator-entries .sui-box-footer {
display:none!important;
}
</style>
<?php
}
}
// issue error if delete attempt
add_action( 'forminator_before_delete_entries', 'wpmu_block_forminator_delete_entry', 10, 1 );
add_action( 'forminator_before_delete_entry', 'wpmu_block_forminator_delete_entry', 10, 1 );
function wpmu_block_forminator_delete_entry( $args ) {
$user = wp_get_current_user();
if ( in_array( 'subscriber', (array) $user->roles ) ) {
wp_die( "You're not allowed to do this!" );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment