So I've created a function that updates several custom fields in a post when the post is created. The idea is to sanitize this information so that I can easily use it for other purposes. The function works fine when I create a post manually. However, I import hundreds of posts directly in to the site (using WP All Import), and for these posts that are imported, it seems that this function does not apply. Currently I'm using the 'save_post','publish_post', and 'new_to_publish' hooks to try to accomplish this. However none of them seem to work. Am I missing something? Is there a better way to accomplish this? Here's abridged version what I have thus far:
add_action( 'save_post', 'sterilize_vehicle_information' );
add_action( 'publish_post', 'sterilize_vehicle_information' );
add_action( 'new_to_publish', 'sterilize_vehicle_information' );
function sterilize_vehicle_information( $post_id ) {
$internet_price = get_field('internet_price',$post_id);
update_post_meta( $post_id, 'internet_price', preg_replace( "/[^0-9]/", "", $internet_price ) );
}
Thanks for the insight!