Add this to your theme’s functions.php
file:
function wpse202681_save_post_action($post_id, $post_object, $update) {
$folder = "/temp/files/";
delFolder($folder);
}
add_action( 'save_post', 'wpse202681_save_post_action', 10, 3 );
// + delFolder() function definition
You will probably have to alter folder paths depending on your /temp/files/
location.
This will execute everytime any post is saved. You can restrict it to only some post type, etc.
Related Posts:
- How do I edit the php/html for a particular post?
- How to replace file_get_contents() with a WordPress Filesystem call
- $wp_filesystem returns NULL. What are the dependencies?
- Can WP plugins access files outside the installation folder?
- Is it better to store images and other files in the root directory or the theme directory
- How to edit php code in WordPress Post file?
- Does WordPress create a new Linux user when creating a new WordPress blog?
- Adding regular php file to site
- Is there a name for trivial WP PHP files like functions.php, archive php entry.php, page.php and so forth?
- How can I create a WordPress dynamic download counter
- Unzip_file causing Media file upload error
- Enabling XSendFile causes 404 for images on WordPress Multisite / Network
- How to add a .php file to WordPress
- When to use Exceptions vs Error Objects vs just plain false/null
- Woocommerce get selected shipping zone id for the current user
- Include files in functions.php
- Display all meta for a post?
- Is there a reason why my wordpress PHP page isn’t loading into my PHP template
- Moving wp-content outside of web root?
- Add to previous posts under post
- How to show order data by multiple ID?
- Print html when custom field has value inside while loop
- how to create and show sessions in word press?
- Categories Template Assistance
- Stop Duplicating Terms in a Foreach Loop
- Generating add_settings_section() calls dynamically
- How to trash multiple post/product programmatically
- Loading jQuery in the footer after removing jQuery migrate?
- Proper way to edit a post via phpMyAdmin without breaking the compare revisions tool
- Sending jsPDF documents to the server
- Unit Test in WordPress
- “before delete post” action fire when the post is updated?
- Register non hierarchical taxonomy and the show meta box in the post type
- Admin username and password
- WordPress excerpt not working
- Random Default Avatar Function
- Custom Text in WooCommerce Order Processing Email Based on Products
- Redirect to another page after submission using wp_mail
- Loop with slider (slider not loading)
- How to set up VS Code for WP plugin/theme development in 2021? [closed]
- Error when adding excerpt to the content through functions.php
- wordpress media library new uploads don’t write to database
- Add data attribute to each li in menu
- Fresh Install WP error – “The site is experiencing technical difficulties” [closed]
- Woocommerce : Can’t get product info in loop
- inserting a post from an extern php file but post content doesn’t show on wp site
- Way to add captions to gallery images by code
- Echo possibly causing custom template formatting conflict
- proper way to add css using functions.php?
- How do I create my own .php file with a code part and echo it on different pages?
- “Undefined index” error when saving empty array with checkboxes
- WordPress comment submit button substitutes/options
- Custom ajax call returns 0 [duplicate]
- HTML table attributes ignored
- How to use wordpress function wp_enqueue_script() in php?
- Parse error: syntax error, unexpected ‘,’
- Create a package of products as one Item in woocommerce?
- How can I include the user id inside of a shortcode php output?
- How to use wp_nav_menu to create custom dropdown menu?
- How to set cookies
- Add a custom class to the body tag using custom fields
- how to edit a specific post slug using a php code?
- Display the video of a post_format Video
- Manually Create PHP Page For A Redirect
- Get All In One SEO Pack to use custom field instead of Content
- Display multi-select box choices in a bullet list [closed]
- Submit form to db
- the_post(); prints out style text into my HTML?
- How do I attach an invoice PDF to an email in the Dukapress plugin for WordPress?
- Calling code from another plugin to custom profile field
- Require()/Include() post template adding extra content
- Approval by Admin to confirm the change
- couldnt show short code atts in category
- “WARNING: Found @$ in the file __ Possible error suppression is being used
- Submiting with problems on one of the options php wprdpress
- Changing ALT-tag for logo in wordpress
- str_replace remove words from title
- Woocommerce checkout page – custom field checkbox value into email
- Help with preg_replace
- Create form which redirects to site in network?
- Advertisement in Loop Posts wordpress
- WooCommerce multiple custom fields code
- How to display last whole post on the homepage
- Custom Plugin Develoment, Form Action
- Restrict File Type Uploads by User on Wordress via functions.php
- Resource 404 error on multisite subdirectory install
- AJAX Returning Way Too Many Posts
- WordPress AJAX load post metadata in modal
- Add point on excerpt post
- Give permission to admin to see user’s page
- add shortcode heading showing multiple time
- List of child pages fetch next results at link click
- Limit ads appearing more than three times
- How does add_action ‘comment_post’ work?
- Showing Subcategory’s Name and Link Instead of Parent Category’s
- reorder a WP_Query, using a dropdown
- Select area and checkbox data is not saving?
- Suppress errors when using global function
- In reading settings posts are set to “blog” and I have page-blog.php but no posts
- using a shortcode in a hyperlink