Skip to content

Instantly share code, notes, and snippets.

@tyxla
Created February 9, 2016 21:55
Show Gist options
  • Save tyxla/f884e1710c13e723bfe2 to your computer and use it in GitHub Desktop.
Save tyxla/f884e1710c13e723bfe2 to your computer and use it in GitHub Desktop.
Fix Signature Gravity Forms field
<?php
add_filter( 'gform_get_form_filter', 'my_fix_gform_signature_field', 99, 2 );
function my_fix_gform_signature_field( $form_string, $form ) {
$replacements = array(
"~<canvas id='input_\d+_~" => "<canvas id='input_" . $form['id'] . "_",
"~id='input_\d+_(\d+)_Container'~" => "id='input_" . $form['id'] . "_$1_Container'",
);
foreach ( $replacements as $find => $replace ) {
$form_string = preg_replace( $find, $replace, $form_string );
}
return $form_string;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment