transition_post_status hook doesn’t have any POST data when publish with Gutenberg [closed]

But you shouldn’t use $_POST inside that hook.

transition_post_status fires when a post is transitioned from one status to another.

It can be caused by anything (not only by sending POST request from editor).

For example here’s the function that is responsible for publishing future posts: check_and_publish_future_post. It’s called only by cron, without sending any POST data at all…

transition_post_status hook takes 3 params:

$new_status (string) New post status.

$old_status (string) Old post status.

$post (WP_Post) Post object.

and you should use mainly these values in your action – you can be certain that they will be passed and will be correct.

You can’t assume anything about the contents of POST request…