Last active
September 7, 2017 21:26
-
-
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/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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