Update Custom Field on Imported Post Creation

There is a hook that worked for me in most case while those 3 hooks you use fail. It’s transition_post_status :

add_action('transition_post_status', 'sterilize_vehicle_information', 10, 3);
function sterilize_vehicle_information( $post, $new_status, $old_status) {

   $internet_price = get_field('internet_price',$post->ID);
   if(  $new_status == 'publish' && old_status != 'publish' ) {
           update_post_meta( $post->ID, 'internet_price', preg_replace( "/[^0-9]/", "", $internet_price ) );
    }
}

Hope this will help.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)