function corp_210517_save_post($post_id, $post, $update) {
    if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
        return $post_id;
    }
    if( wp_is_post_revision( $post_id ) ) {
        return;
    }
    $etype = get_post_meta( $post_id, 'ver_type_select', true );
    $regurl = add_query_arg(
        array( 
            'pone' => $post_id,
            'ptwo' => $etype
        ), 
        get_permalink(118)
    );
    update_post_meta($post_id,'reg_url',$regurl);
    //log_it($regurl);
}
add_action( 'save_post_corporation', 'corp_210517_save_post', 10, 3);  

Let me explain what is happening here. For new post, after publish reg_url still remain blank because on publish get_post_meta( $post_id, 'ver_type_select', true ); is not returning the new meta value instead it takes the previous value, which is null.

Similarly, on updating the post, get_post_meta( $post_id, 'ver_type_select', true ) is returning the older value not the current updated value.

I don’t what I am doing wrong! seems like hook or priority issue causing this problem. Please help

This is the framework https://github.com/humanmade/Custom-Meta-Boxes, using to create metabox.

Read more here: Get updated meta value after post update or published (custom post type) using hook


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: