Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 59525

Saving meta with useEntityProp setMeta – sanitization needed?

$
0
0

Replies: 0

Hi, I’m using blocks (vs meta boxes) to allow users to insert and save post meta for custom post types. WordPress provides a handy function setMeta, part of useEntityProp, that saves meta to the DB. A review of how this works is here:

https://developer.wordpress.org/block-editor/how-to-guides/metabox/meta-block-3-add/

Their example function looks like this:

function updateMetaValue( newValue ) {
    setMeta( { ...meta, myguten_meta_block_field: newValue } );
}

My question is: do we need to sanitize user inputs prior to saving, or does setMeta (or something else under the hood) do this for us? If we need to do it ourselves, does WP provide any sanitization functions (like it does for PHP)?

Thanks!

  • This topic was modified 44 minutes ago by edanzer.

Viewing all articles
Browse latest Browse all 59525

Trending Articles