Opened 5 years ago
Last modified 11 months ago
#53425 new enhancement
Allow meta_input to be updated through user input
| Reported by: | freepius | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Editor | Version: | 5.8 |
| Severity: | normal | Keywords: | has-patch reporter-feedback |
| Cc: | Focuses: |
Description
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 _wp_get_allowed_postdata() function like that (line 224):
/** * 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 :-)
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Hey @freepius it seems that this never moved forward
In [44047] it was first stated that
meta_inputwas never intended to be updated through user input. But it seems that you think that it shouldI cannot get enough context of why this decision was taken because I can't see any tickets associated.
Maybe, you have found a specific scenario that you can better explain and maybe
meta_inputshould be removed from that array all around instead of creating such ad-hoc filterCan you comment or provide more information to get more insight about your requirements?