Home › Forums › Gutenberg › Block Data changes after field change › Reply To: Block Data changes after field change
I found another option, you can add to wp.data.dispatch(‘core/editor’) meta that isn’t saved and can be sorta a transient between blocks.
Register a meta field to a post type and then use dispatch to save data. The interesting thing about this is you don’t need to save it to database as Gutenberg editor has an in memory data store for meta until you actually hit the save button.
register_post_meta(
'post',
'acf_sync',
array(
'auth_callback' => function() {
return current_user_can( 'edit_posts' );
},
'sanitize_callback' => 'sanitize_text_field',
'show_in_rest' => true,
'single' => true,
'type' => 'string',
)
);
wp.data.dispatch('core/editor').editPost({meta: {acf_sync: JSON.stringify(sync)}});
const meta = wp.data.select('core/editor').getEditedPostAttribute('meta').acf_sync;
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.