Support

Account

Home Forums Gutenberg Update ACF meta via native Gutenberg block?

Helping

Update ACF meta via native Gutenberg block?

  • Hi. I have a “legacy” ACF field, and I would like to use a native Gutenberg Meta-Block to update the field, as per explanations in the block editor handbook. This is the relevant part

    const [ meta, setMeta ] = useEntityProp( 'postType', 'postType', 'meta' );
     
    	 const metaFieldValue = meta._legacyField;
    	 const updateMetaValue = ( newValue ) => {
    		 setMeta( { ...meta, _legacyField: newValue } );
    	 };
     

    Once I redefine the legacy field in the Meta-Block-Plugin using register_post_meta(), the Block will be able to *read* the field value. However, when attempting to update the field value, I get a 403 response from the REST API.

    Updating the field value via the standard ACF metabox below works just fine, as does updating a new meta-key defined within the plugin. The problem appears only when the meta to be updated key has been defined in ACF.

    Is there any way to update ACF-defined metafields via a native Gutenberg metablock / rest-api? Some people suggest that ACF meta data needs a specific format for the update – could that be the problem?

    cf https://stackoverflow.com/questions/53596688/update-acf-fields-inside-layout-via-wp-api

    Thanks!

  • Did you ever solve this? How do you load the ACF meta field for your Gutenberg plugin?

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.