Bricks erases custom metadata values

Bricks Version**: 1.5.7
Browser**: Chrome 107
OS: macOS

I’ve coded (no plug-ins) some custom metadata fields for posts. If I input and save the metadata using Gutenberg / Wordpress Editor (which is the only way, because that’s where the input fields are), it works as expected.

However, if I then edit the post content in Bricks and hit save in the builder, the metadata is lost. I’m guessing it’s because the custom metadata’s “save_post” action also runs when saving the post from Bricks Builder - and it replaces the previous values with null because the input fields are not present in the builder.

I’ve tried adding a “if ( ! bricks_is_builder )” condition to the save_post function, but it does not work.

Any ideas on how I may implement a fix?

if it helps, here is the save_post function:

// Metaboxes Save

function frsn_cpt_trabalhos_meta_save( $post_id ) {

		if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ||  ! is_admin() ) {
			return $post_id;

		if ( ! bricks_is_builder() ) {
			update_post_meta( $post_id, 'frsn_cpt_trabalhos_cliente', $_POST['frsn_cpt_trabalhos_cliente'] );
			update_post_meta( $post_id, 'frsn_cpt_trabalhos_segmento', $_POST['frsn_cpt_trabalhos_segmento'] );
			update_post_meta( $post_id, 'frsn_cpt_trabalhos_herobg', $_POST['frsn_cpt_trabalhos_herobg'] );
add_action( 'save_post', 'frsn_cpt_trabalhos_meta_save' );

Caio Frison

Hey guys, I’ve found the solution - and it had nothing to do with Bricks.

I’ll just leave this here for anyone facing a similar issue: I had forgotten to validate nonce. Once I did, everything worked as expected.