Skip to main content
4 of 6
added 241 characters in body
Lee
  • 155
  • 2
  • 15

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?

EDIT:

It does seem teh file is being run but for some odd reason it is not outputting the custom field values. It is a simple php file with a loop using wp_query and it works fine when I go direct to it. - any ideas what it coule be?

Lee
  • 155
  • 2
  • 15