Hello,
I try to find a way to set a value after a custom post type is (first) published.
This was my first try but it doesn't seem to work:
add_action('transition_post_status', 'send_new_post', 10, 3);
function send_new_post($new_status, $old_status, $post) {
if('publish' === $new_status && 'publish' !== $old_status && $post->post_type === 'cpt') {
rwmb_set_meta( $post->id, "field_id", "test" );
}
}
I could verify that $post->id is available within the if statement and that I will be inside the if statement, so is there a error with rwmb_set_meta?