I have a custom post type that always do math operation to its post_meta and other custom post type post_meta. For example: post-type 1 = cpt_product_order post-type 1 post_meta = cpt_pm_product_order post-type 2 = cpt_product post-type 2 post_meta = cpt_pm_product_stock There's a cpt_product with cpt_pm_product_stock = 100, frontend operation enable specific user made order by inserting new cpt_product with post_meta cpt_product_order of 10 will substract cpt_pm_product_stock to 90 100 cpt_pm_product_stock - 10 cpt_product_order = 90 cpt_pm_product_stock cancelling order will delete/trash …
As told in the title, I am looking for a way to prevent users to delete comments from the trash. Only admins should be able to. I tested the scripts at: Function to prevent users from trashing comments But it doesn't work, probably since 2013 a few things have changed :) Thank you for help!
I need to restrict the button "EMPTY TRASH" and make it delete only the posts only if the logged in user is the creator. I tried to use the wp_trash_post and i need to decide in the function if i need to continue to trash or not. How do i tell WordPress NOT to empty the trash from specific posts?
what does it take to display the Recycle Bin in my own Custom Post Type? function my_custom_post_specialist() { $labels = array( 'name' => _x( 'Terapeuci', 'post type general name' ), 'singular_name' => _x( 'Terapeuci', 'post type singular name' ), 'add_new' => _x( 'Dodaj nowego specjalistę', 'book' ), 'add_new_item' => __( 'Dodaj nowego specjalistę' ), 'edit_item' => __( 'Edytuj specjalistę' ), 'new_item' => __( 'Nowy specjalista' ), 'all_items' => __( 'Wszyscy specjaliści' ), 'view_item' => __( 'Pokaż specjalistę' ), 'search_items' => …
I have a function which processes custom metabox data on saving my custom post type: add_action('save_post_customtypehere','myown_save_customtype_fn'); function myown_save_customtype_fn($ID) { ... } However, the function also runs when I trash items within this CPT (I guess it's effectively saving the post to change post_status to trash). Without the metabox being present, my function ends up clearing things like post_name (not great if I need to restore from trash!). I have two thoughts but can't quite get across the finishing line with …
I'm new in WordPress. I have to restrict access to the Trash for all users except the administrator. All users CAN move to the Trash, but only admin can delete permanently or restored. I do not know php well, if there is some magical plug or another easy way to do this?
it is possible once called a before_delete_post action not to allow WP to delete post on certain condition? something like e this: add_action( 'before_delete_post', 'my_custom_delete', 10); function my_custom_delete($wp_post_id) { if (get_post_type($wp_post_id) == 'my_custom_post_type') { if(condition_is_true($wp_post_id)){ error_log("do something to block WP deleting the post"); notify_the_user(); } else { error_log("we can delete the post"); } } }
I accidentally deleted about 20 blog posts and they were in my trash folder for over a month and now have permanently deleted. I was wondering if there's a way to recover these? For example I have seen mention of MySql database and phpMyAdmin, and was wondering if these would be applicable in my case and, if so, how do I use them? Thanks in advance!
I need only "move to trash" bulk action and I want to set it as the default bulk action. Then, I will hide the select field with css. To delete a post, I will just put a tick in a checkbox and then hit the ok button to delete. How can I set "move to trash" as the default bulk action?
I have a CPT "foo". I want to totally disable the "trash can" feature, so that any time on the the CPTs is deleted, it is simply permanently removed. Not put in the trash can. How can I do this programatically?
My website was working fine until today, I just discovered that all comments made goes straight to trash. I did not install new plugins, I don't have akismet. It just started. I have deactivated all my plugins and yet the issue persists. I don't know what the issue is. Is there any code I need to add to my functions.php file to make this stop ?
By default Wordpress assigns the draft status to a post that has been untrashed. I would like to assign the pending status to posts that are untrashed. This seems to be possible with wp_untrash_post_status, but I can't seem to find the proper way to use it. I have this in my code : add_action( 'untrash_post', 'my_function' ); function my_function( $post_id ) { apply_filters( 'wp_untrash_post_status', 'pending', $post_id, 'pending' ); } What am I doing wrong ?
I have a Wordpress 5.4.1. website, with Woocommerce 4.1.1. installed. It seems that orders which have the status "Cancelled" move to Trash automatically after one month passes (from the order date). Is there a way to disable this feature? I want all orders to stay as Cancelled, in order to keep them in the database.
All of the reusable blocks on one of my sites were deleted last week. Not just deleted, but the trash emptied. I've already had a security vendor audit the site, and they concluded there was no hack, it was done by a legitimate user. No one was using the database directly, so it had to be done in wp-admin. The only way I can find for reusable blocks to be completely deleted is to visit the page http://example.com/wp-admin/edit.php?post_status=trash&post_type=wp_block. (On that …
I have set up a custom post type, which user can edit from the frontend. I'm using wp_delete_post() to allow users to delete a post they created. It works, but the posts get deleted instead of being moved to trash.I have tried moving a post to the bin via the backend and it works like you would expect it, the post is moved to the Bin. So I'm not sure why the wp_delete_post doesn't work the same way, but permanently …
I want that only Admin and Editor roles can use the 'Move to Trash' option in my blog, and other users will get the 'Move to Draft' option instead. Like inside of the 'Quick Edit' / 'Bulk Actions' options in All posts of the Dashboard, and the Post editor side bar:
I'm currently working on developing a plugin with a custom post type of "Dealer Location". (Not relevant to question, just a bit of background) When a post is in the trash and "delete permanently" is pressed, I need to remove this piece of meta from each user. When a post/posts are in the trash and "empty trash" is pressed, I need to run through EACH location being deleted and do something. I have an extremely basic function just to test …
I'm trying to create a short code to delete post that user publish from the front end of my site. I've tried the short-code below but I keep getting the error "The link you followed has expired." Kindly see image screenshot below. //Shortcode to delete post function delete_my_posts() { ob_start(); $url = get_bloginfo('url'); if (current_user_can('edit_post', $post->ID)){ echo '<a class="delete-post" rel=”nofollow” href="'; echo wp_nonce_url("$url/wp-admin/post.php?action=trash&post=$id", 'delete-post_' . $post->ID); echo '">Delete post</a>'; } return ob_get_clean(); } add_shortcode( 'delete_me', 'delete_my_posts' ); Screenshot: https://imgur.com/a/PMB1uU4 Can …
I found a solution of removing featured image related to the post when delete the post from this article but, I want to remove all the uploaded media also with post removing. Delete all WP image gallery (included generated thumbnails) that are attached to a post. How can I do this?
I want to do the following in a plugin: - hook to untrash_postwith a custom function - do some checking inside custom function - cancel actual post restoring (untrashing) I've tried with remove_action but doesn't seem to work. Can you point me into the right direction? Code sample: add_action( 'untrash_post', array( __CLASS__, 'static_untrash_handler' ) ); ..... public static function static_untrash_handler( $post ) { // check stuff // prevent post from being restored. How ? } Should I return something to …