[wp-trac] [WordPress Trac] #54122: Action hook transition_post_status not properly working in Block Editor
WordPress Trac
noreply at wordpress.org
Tue Sep 14 14:22:56 UTC 2021
#54122: Action hook transition_post_status not properly working in Block Editor
--------------------------------------+-----------------------------
Reporter: vinoth06 | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 5.7
Severity: normal | Keywords:
Focuses: administration, rest-api |
--------------------------------------+-----------------------------
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
{{{#!php
wp_get_post_terms( $post->ID, get_object_taxonomies( 'post' ) );
}}}
2. But in block editor, hope we are separately storing the category and
terms(Please correct me if am wrong)
3. 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.
4. 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
--
Ticket URL: <https://core.trac.wordpress.org/ticket/54122>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list