Form element custom actions

Hello,

Trying to figure out how to make the custom elements work and following along here: Form Element – Bricks Academy.

First question, are the code snippets on that page fragments? I don’t understand why they aren’t closed, they open with <?php but there's no closing ?>?

I eventually want to be able to send a custom POST request to Mailchimp so that I can conditionally add subscribers to different lists based on what checkboxes are ticked. Current Mailchimp implementation doesn’t do that, so I’m trying to homebrew one.

There’s multiple problems, and I have multiple questions. I’ve been testing the same simple code as follows. The script tags are correct in the site, I had to change them here so they would show up in this editor.

<?php echo <> script console.log('test') script <> ?>
  1. Where/how am I supposed to add PHP code? The Code element prints everything as text unless I wrap it in HTML wrappers (e.g. <?php and ?>) which, from what I understand, is the only way. Adding code in the page settings header/footer also doesn’t seem to work; the code doesn’t run and I just see " console.log(“test form css”)'; ?> " in the header as plaintext. There’s nothing in the documentation to explain this. I’m not using any other plugins for reference, just Bricks.

  2. How do I link actions? I can create a function and call it to print to console (which works successfully), but I can’t trigger the function from form submittal at all. I double checked, the Custom action is selected on the form element, and the form “submits” successfully (with the specific Success text showing up). However, the form callback function does not get triggered no matter what. I have tried adding the action using “add_action( ‘bricks/form/custom_action’, ‘my_form_custom_action’, 10, 1 );” but it doesn’t work.

The custom code page and YouTube video also only talks about custom CSS, not custom PHP or anything close to similar so I can’t really use that as reference.

Thanks for reading.