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

WordPress Trac noreply at wordpress.org
Thu Jan 4 14:56:35 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:                |     Focuses:
--------------------------+------------------------------
Changes (by henry.wright):

 * keywords:  reporter-feedback =>


Comment:

 Hi @danieltj

 > I'm just curious, but why do you need to validate those fields prior to
 saving as that already happens on post save?

 Perhaps I should have been more clear. A hook will allow for custom
 validation to be done. If WordPress validates already then that's great
 but the key word here is custom.

 > Having said that, there is a hook called pre_post_update that is run
 when something is updated

 As you mentioned in your comment, the {{{pre_post_update}}} hook will
 execute only if {{{$update}}} evaluates to {{{true}}}. The hook I'm
 requesting should apply also to new posts.

 > 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.

 {{{save_post}}} is executed after the post has been saved. This won't be
 helpful if you need to perform custom validation before the post is added
 to the database.

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


More information about the wp-trac mailing list