Skip to main content
3 of 6
code spacing
EAMann
  • 32.2k
  • 9
  • 88
  • 147

run script on publish

I am trying to run a script when a user publishes / updates a post.

I am using the filter: wp_insert_post_data

The problem I am having is the script is a php file outside of WordPress but on the same site (It works fine if i go direct to it) that just needs to be run. I tried to include the file using the filter but that stopped the post being updated for some reason.

This is my current code:

function updateFeed( $data , $postarr) {
   include 'jobsfeed.php';  
   return $data;
}

add_filter( 'wp_insert_post_data' , 'updateFeed' , '99', 2 );

Is there any way to be able to run this script?

Lee
  • 155
  • 2
  • 15