Prevent users to delete comments from trash
Prevent users to delete comments from trash
Prevent users to delete comments from trash
You could use get_post_status(): function is_trash( $post_id = 0 ) { 0 == $post_id and $post_id = get_the_ID(); return ‘trash’ === get_post_status( $post_id ); } Side note: To get a list of all registered post status objects use get_post_stati() – yes, that’s wrong.
Where did you see trash_comment? It is no original WordPress core function, though. Maybe some part of a plugin/theme? So in short: use wp_trash_comment – if you must. There is, however, an action called trash_comment. Maybe this is what got you confused…?
Once a post is moved to the trash and deleted, it’s gone from the database. The only way to recover it is from an earlier database backup. Do you have a backup? Does your webhost have a backup?
I found the answer – this contains sample code which helped me resolve the issue. https://codex.wordpress.org/WordPress_Nonces
You can use add_filter() for post_row_actions to filter out the ones you don’t want, add in the functions you do want. Like so: <?php /** Plugin Name: (wpse) Draft vs. Trash Posts */ add_filter( ‘post_row_actions’, ‘my_plugin_update_actions’, 10, 2 ); function my_plugin_update_actions($actions, $post) { $capability = ‘promote_users’; $role=”Administrator”; // Choose what you want to check against. … Read more
You should basically never dieon an action. It is likely to leave the system in unstable state. The right way to solve your issue to to deny users from deleting the post by using the user_has_cap filter that enables you to override the default permissions users have. The added value is that users will (should) … Read more
The $id variable is never set. Use this instead: wp_trash_post( $postid );
Unless you have a backup of your database then most probably your page is unfortunately gone forever. You could try contacting your hosting provider and ask if they have a backup stored somewhere.
A clue: backoffice > woocommerce > settings > tab account/confidentiality > at bottom “Retention of personal data” > change date for the cancelled orders