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
- Is there a way to get a path to the theme directory without the server name?
- How to implement a custom sliding banner? [closed]
- metabox displaying on incorrect page
- I would like to alert message while another user is editing or update data in wordpress admin panel, what should i do?
- Header location [closed]
- how to loop through blog posts in php
- Saving User Input to PHP Variable
- Tittle of post instead of tittle of page in php
- It’s not showing full content for posts pages in wordpress “[…]” while customing some changes in the style.css file [closed]
- How do I convert a custom field to a php date format? [closed]
- JSON Object Value Show Undefine
- Create an if statement based on page_id
- Require Credits Footer
- I’m not able to get access $wpdb in my php file in wordpress
- append special url end of my website urls
- How to crop featured image in different sizes?
- How to find out the URL of enabled theme(s)?
- Submit cf7 form to cfdb as pdf/BLOB [closed]
- An automatic way to crop images of different sizes
- Javascript code not working – $ is not a function error
- Blog listing not showing dates for every post and arrow missing off image
- Show post like this image in my newssite [closed]
- Undefined variable notice [closed]
- How do I remove spammy links in WP theme footer?
- Pagination not working properly
- Detecting IP Address of someone using ‘copy’ function [closed]
- Display biography post for today’s birthday person
- php grabbing every post made?
- Functions.php file in a custom child theme messed up without backup
- paginate_links() returns NULL instead of the pagination links, but pagination is actually happening
- What is proper way to use the php if statement? [closed]
- is it possible to create cart functionality without woocommerce? [closed]
- php snippets in html are being commented out
- Running a php code after User clicks a button? [closed]
- Parse error: syntax error, unexpected ‘}’ in C:\xampp\htdocs\admin\products.php on line 148 [closed]
- get user role. parameter id return type string [closed]
- Please help to know why single.php crashes after I add this code [closed]
- What does this if-statement do?: if($pages=’ ‘) {}
- Please help! Parse error: syntax error, unexpected ‘
- Can you not edit the HTML and PHP of your WordPress without paying?
- Really slow WordPress site [closed]
- Retrieve Array from within Array [closed]
- $_html is empty when var dumped
- How to improve wordpress site creation process to increase productivity.
- $post->ID calls for current page, but what is the code to call for any new page created and published in WordPress?
- Your PHP installation appears to be missing the MySQL … After deleting and restarting from cpanel
- How can I fix my pagination?
- How to create shortcode of this PHP code
- How to increase excerpt length in wordpress? [duplicate]
- Insert PHP into wordpress page [duplicate]
- Are WordPress & PHP objectively and based on evidence going to die because the future is made of frontend rendering instead of server side rendering? [closed]
- Advanced Custom Fields Show PHP in Text Areas
- Event plugin problem any one solve .? [duplicate]
- Not able to see the error [closed]
- how to Show BEFORE TEXT before in wordpress get_comment_meta [closed]
- What is the wrong with this function to enqueue the scripts and styles to the theme? [closed]
- Force array to be a string [closed]
- How to remove the intro animation which appears during the load up of some WordPress themes? [closed]
- Adding jquery using php function
- New to WordPress & Freelancing [closed]
- How to hide .js files on wordpress website using php or wp plugins or any? [closed]
- Add a “Next Post” & “Previous Post” styled button manually to a post
- How do I link the side images?
- How to send push notification in android using php? [closed]
- How to store the_post_thumbnail() value in a variable
- Echo get_option displays as text
- How to use multiple 404 Error Pages in WordPress
- How can I get is_page(Current_URL)?
- Parse error: syntax error, unexpected ‘}’ in
- Assign new post author IF another user in custom field on post transition
- Use HTML Form Data in PHP Function – WordPress Admin Page
- Sorting Problem
- WordPress add parameters with friendly url structure
- Create and publish a new post every Monday, listing the post titles and links to the posts published during the previous week
- Different behaviour between “include_once” and directly echoing out html code?
- Front-end major break after upgrade PHP 8.0 [closed]
- WP query with variables gives no result for specific user
- “Missing header/body separator” error with wp_remote_post()
- How to automatically convert images to WebP on WordPress?
- WP Fatal error: Call to undefined function get_template_directory_uri()
- wp_enqueue_scripts with JS script as a string
- Blog Posts not sorted and pagination not adjusted after filtering some category
- Why can’t I enter the wordpress admin interface?
- Is there a better way to output HTML as a shortcode?
- Remove default Image Sizes
- Remove Unused Menu Locations
- base64_encode conflict with convert_smilies in wordpress
- Need help with Deprecated: Non-static error when update PHP 7.4 -> 8.1 with Dyad 2 theme