WordPress hook after post content and meta update


I want to update one of my meta field and redirect and I am using post_updatedhook. Here is my code.

function job_publish_status( $post_ID, $post_after, $post_before ) {
   $job_published_date = get_the_time("Y-m-d", $post_ID);
   $expire_date = date('Y-m-d', strtotime($job_published_date. ' + 60 days'));
   update_post_meta($post_ID, '_job_expires', $expire_date);
   $url = get_site_url();
   $url = $url.'/wp-admin/post.php?post='.$post_ID.'&action=edit';
   wp_redirect( $url );
add_action('post_updated', 'job_publish_status', 99, 3 );

It is updating this _job_expires meta field and redirecting correctly. When I edit post content and title, its updates title and content but it is not updating other meta fields in this post.
Is there any hook which triggers after post content update and meta fields update ?

, wplearner 2 years 2019-12-27T16:18:57-05:00 0 Answers 84 views 0

Leave an answer