Make WordPress Core

Opened 3 years ago

Last modified 3 years ago

#54122 new defect (bug)

Action hook transition_post_status not properly working in Block Editor

Reported by: vinoth06's profile vinoth06 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.7
Component: General Keywords: reporter-feedback
Focuses: administration, rest-api Cc:

Description

Hi,

Scenario:
We have to get the post category/terms on post status "Pubilsh" (First time publish).

So we have used transition_post_status action hook to get the old and new status of the post. We can able to get the post category/terms when we do first publish in Classical editor. But the same is not working in Block editor.

Some Investigation (Might be wrong)

  1. On classical editor, while we publish the post, we are getting the Category on $_POST, so the wp_insert_post() will store the category before it reaches the action hook transition_post_status . So we can able to get the post terms using
    wp_get_post_terms( $post->ID, get_object_taxonomies( 'post' ) );
    
  1. But in block editor, hope we are separately storing the category and terms(Please correct me if am wrong)
  1. In block editor on old post status as "new" and new post status as "publish" (This would the first time publish of that post), in wp_insert_post() we are not getting the category or terms to store in that post, so while entering transition_post_status action hook, we are not able to get the corresponding selected category instead we are getting the Uncategory for that post as a default.
  1. In block editor we are getting the corresponding post category for action hook transition_post_status, but the post status are incorrect, the old post status and new post status is "publish", which is equivalent to update, so we are not able to identify whether the post has been published first or update.

Please let me know if the above is unclear.

Thanks
M A Vinoth Kumar

Change History (3)

This ticket was mentioned in Slack in #core-test by hellofromtonya. View the logs.


3 years ago

#2 @justinahinon
3 years ago

  • Keywords reporter-feedback added

Hello @vinoth06 ,

Thanks for opening the ticket. We have discussed this during today (September 21) test team triage meeting.

We were not quite sure if this is a bug, or might be better asked in support forum.

Could you add the steps to reproduce the issue you are experiencing?

Note: See TracTickets for help on using tickets.