[wp-trac] [WordPress Trac] #51310: WordPress app and many plugin is malfunctioning. Publish/Edited post activity is being updated twice in system.
WordPress Trac
noreply at wordpress.org
Thu Sep 24 02:01:48 UTC 2020
#51310: WordPress app and many plugin is malfunctioning. Publish/Edited post
activity is being updated twice in system.
-------------------------------+----------------------
Reporter: arbn | Owner: (none)
Type: defect (bug) | Status: closed
Priority: normal | Milestone:
Component: Posts, Post Types | Version: 5.5.1
Severity: major | Resolution: invalid
Keywords: | Focuses:
-------------------------------+----------------------
Changes (by SergeyBiryukov):
* keywords: needs-patch =>
* resolution: => invalid
* status: new => closed
* component: Plugins => Posts, Post Types
* milestone: Awaiting Review =>
Comment:
Hi there, welcome to WordPress Trac! Thanks for the report.
As previously noted in comment:5:ticket:19074, `save_post` fires twice for
any post type that supports revisions:
* First, it fires for a new revision being created.
* Then, for the post itself being updated.
When using the `save_post` hook, you should check the post type of the
post object before doing anything. Some examples might be helpful:
https://developer.wordpress.org/reference/hooks/save_post/#user-
contributed-notes
Alternatively, you can use the
[https://developer.wordpress.org/reference/hooks/save_post_post-post_type/
save_post_{$post->post_type}] hook that only fires for specific post
types.
This works as intended, I don't see a bug here.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/51310#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list