Skip to content

Instantly share code, notes, and snippets.

@MjHead
Last active December 6, 2024 21:44
Show Gist options
  • Save MjHead/dd212ba78af45f17efb5b08c15710c50 to your computer and use it in GitHub Desktop.
Save MjHead/dd212ba78af45f17efb5b08c15710c50 to your computer and use it in GitHub Desktop.
Form shortcode for JetFormBuilder
<?php
add_shortcode( 'my_jet_form', 'my_jet_form_shortcode' );
function my_jet_form_shortcode( $atts = array() ) {
$atts = shortcode_atts( array(
'id' => false,
'submit_type' => 'reload', // or ajax
'required_mark' => '*',
'fields_layout' => 'column', // or row
), $atts );
$id = ! empty( $atts['id'] ) ? absint( $atts['id'] ) : false;
if ( ! $id ) {
return;
}
unset( $atts['id'] );
$builder = new \Jet_Form_Builder\Blocks\Render\Form_Builder( $id, false, $atts );
$messages = jet_form_builder()->form_handler->get_message_builder( $id );
ob_start();
$builder->render_form();
$messages->render_messages();
return ob_get_clean();
}
@bmcontentcreation
Copy link

What does this do?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment