[wp-trac] [WordPress Trac] #53425: Allow meta_input to be updated through user input

WordPress Trac noreply at wordpress.org
Wed Jun 16 09:38:54 UTC 2021


#53425: Allow meta_input to be updated through user input
-------------------------------+-----------------------------
 Reporter:  freepius           |      Owner:  (none)
     Type:  enhancement        |     Status:  new
 Priority:  normal             |  Milestone:  Awaiting Review
Component:  Posts, Post Types  |    Version:  trunk
 Severity:  normal             |   Keywords:  has-patch
  Focuses:                     |
-------------------------------+-----------------------------
 Hi everyone!
 This is my first ticket on WordPress trac!

 Since 2 years and this changeset [44295], it's not possible anymore to
 insert/update metadata through user input using **meta_input** entry.

 Indeed ''_wp_get_allowed_postdata()'' remove the ''meta_input'' entry from
 ''$_POST''. Therefore the ''wp_update_post()'' function, then the
 ''wp_insert_post()'' one receive data without ''meta_input''.


 I check the code a lot, and there is no hooks to re-inject properly the
 ''meta_input'' entry. (all the hooks come too late, after post
 inserting/updating).

 I will finally get to my goal, but in an ugly and heavy way.

 I propose to introduce a new hook to filter the not allowed post data
 fields, changing ''[https://core.trac.wordpress.org/browser/trunk/src/wp-
 admin/includes/post.php#L214 _wp_get_allowed_postdata()]'' function like
 that (line 224):

 {{{#!php
 /**
  * Filters the not allowed fields before to remove them from post data.
  *
  * By default, meta_input, file and guid are not allowed in post data.
  *
  * @param array $not_allowed  Default not allowed post data fields.
  * @param array $post_data    Array of post data.
  *
  * @return array Not allowed post data fields.
  */
 $not_allowed = (array) apply_filters( 'not_allowed_postdata', array(
 'meta_input', 'file', 'guid' ), $post_data );

 return array_diff_key( $post_data, array_flip( $not_allowed ) );
 }}}

 Thanks.
 Have a nice day :-)

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/53425>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list