[wp-trac] [WordPress Trac] #43019: Hook to validate post form data before save

WordPress Trac noreply at wordpress.org
Thu Jan 4 13:46:06 UTC 2018


#43019: Hook to validate post form data before save
-------------------------------+------------------------------
 Reporter:  henry.wright       |       Owner:
     Type:  enhancement        |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  General            |     Version:
 Severity:  normal             |  Resolution:
 Keywords:  reporter-feedback  |     Focuses:
-------------------------------+------------------------------
Changes (by danieltj):

 * keywords:   => reporter-feedback


Comment:

 I'm just curious, but why do you need to validate those fields prior to
 saving as that already happens on post save? Having said that, there is a
 hook called `pre_post_update` that is run when something is updated,
 although not when something is saved for the first time mind you.

 Useful links for this hook:
 1. https://core.trac.wordpress.org/browser/tags/4.9/src/wp-
 includes/post.php#L3371
 2. https://developer.wordpress.org/reference/hooks/pre_post_update/

 There are some filter hooks you could use though within the
 `wp_insert_post` function if you wanted to check data that is submitted,
 but like I said; it's validated when run through the function.

 If you're wanting to validate custom meta data for a post, you can still
 use the `save_post` hook and do your own custom validation there but it
 depends on your use case as to whether that's helpful or not.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/43019#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list