I wonder if somebody wouldn’t mind helping me with a problem, please.
I’m using Bricks and Metabox.
I have two buttons on a page. I’d like to hide one button if the Metabox field is empty and another to hide if the Metabox field is not empty. The Metabox field type is a URL field. The reason for the 2 buttons/links is that I have a button to take users to a contact form. I’ve used it as place holders my services page while I build out each service page. Each service is in a query loop. As I build out each page, I’ll swap to the second button to take the user to the service page.
I can hide the button just fine if the Metabox field is empty using the conditions in Bricks.
Would anyone know how to hide an element in bricks if a Metabox field is populated by any chance?
I edited the post and changed it to a possible bug.@timmse
I used a global button that didn’t work but worked fine when I added the plain button. The condition below button only shows if the button is blank below.
I might oversee some details of this concrete scenario but I think I found a way to make it work for global elements using the bricks/element/render hook. So this might be a temporary workaround:
add_filter( 'bricks/element/render', function( $render, $element ) {
/*
* Print (global) element ID for global elements.
* Use this if statement to find your global element's (global) ID.
* Remove or comment out this if statement after finding the correct ID!
*/
if ( $global_element_id = $element->element['global'] ) {
printf( '<pre>Global Element ID: %s</pre>', $global_element_id );
}
/*
* Replace 'cyefwp' with your global element ID
* and use whatever custom logic to output the
* element or not.
*/
if ( $element->element['global'] === 'cyefwp' ) {
return ! empty( rwmb_meta( 'global_button_url' ) );
}
return $render;
}, 10, 2 );
The global button appears even if I set the condition to not empty or empty and the opposite. I wondering if it’s worth someone else also testing this too.
That’s strange. Would you be so kind as to send temporary login credentials, information about where to find the issue, and a link to this thread to help@bricksbuilder.io using the email address you used during the purchase?