Edit:
In a plugin I am developing, I need to store payments, IPN and transactions for customers in both frontend and backend. However I am concerned that the admin will use his actions power to delete the transactions or financial data from site which has bad implications.
Question
How can I prevent the admin from deleting payments/financial data in a way that ensures that I’m not trying to restrict admins too much, but also takes customer information and financial data as high priority. I’m not asking what’s the better way for me to do it? But rather asking what’s the better way for WordPress community (as administration, as a customer) as I am trying to avoid future complaints about the way implemented to do this action.
What I currently have
/**
* Constructor
*/
public function __construct() {
// Do not allow payments and transactions to be trashed
add_action( 'wp_trash_post', array( $this, 'disable_trash' ) );
add_action( 'before_delete_post', array( $this, 'disable_trash' ) );
}
/**
* Disable trash
*/
public function disable_trash( $post_id ) {
global $post_type;
if ( in_array( $post_type, array( 'payment', 'transaction' ) ) ) {
wp_die( __( 'You are not allowed to trash payments or transactions.', 'xxx' ) );
}
}