save_post
and new_to_publish
is enough, with some checks, to update post metadata. And you don’t need the redirection.
<?php
/**
* Update Postmeta.
*
* @param integer $post_id Post ID.
*/
function wpse355298_job_publish_status( $post_id ) {
// Check autosave.
if ( wp_is_post_autosave( $post_id ) ) {
return $post_id;
}
// Check post revision.
if ( wp_is_post_revision( $post_id ) ) {
return $post_id;
}
// Check permissions.
if ( 'post' === $_POST['post_type'] ) {
if ( ! current_user_can( 'edit_post', $post_id ) ) {
return $post_id;
}
}
$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 );
}
add_action( 'save_post', 'wpse355298_job_publish_status' );
add_action( 'new_to_publish', 'wpse355298_job_publish_status' );