Skip to content

Instantly share code, notes, and snippets.

@Shelob9
Last active September 7, 2017 21:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shelob9/4554ddcb82fe5a14ec92d10728087826 to your computer and use it in GitHub Desktop.
Save Shelob9/4554ddcb82fe5a14ec92d10728087826 to your computer and use it in GitHub Desktop.
Filter to prevent Caldera Connected Forms from showing in the form. See: https://calderaforms.com/doc/connected-caldera-forms-hooks/
<?php
/**
* Conditionally prevent Caldera Forms Connected Forms from adding the submit or next button to a form.
*
* Requires connected forms 1.1.2 or later
*/
add_filter( 'cf_form_connector_add_next_btn',function( $use, $is_submit, $new_form, $connected_form_id, $process_record){
//IMPORTANT - Change this to the ID of the form <em>in the sequence</em> That you want to block the submit/next button from loading on.
//IMPORTANT - Change this to the ID of your connected forms sequence.
$form_id = 'CF599efb48bba5e';
if( 'CF598a1253e89e6' === $connected_form_id && $form_id === $new_form[ 'ID'] ){
$field_values = array();
if( isset( $process_record[ $connected_form_id ]) ){
$field_values = $process_record[ $connected_form_id ][ 'field_values' ];
}
//Do some conditional logic based on field value, for example:
if( isset( $field_values[ 'fld_7683514'] ) && 'Yes' !== $field_values[ 'fld_7683514'] ){
//prevent submit button from showing
$use = false;
}
}
return $use;
}, 15, 5 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment