Snippi
A super awesome snippet tool.
- 1.
// apply to a specific form ID 6 and field ID 123
- 2.
add_filter( 'gform_field_input_6_123', 'my_custom_function', 10, 5 );
- 3.
- 4.
function my_custom_function( $input, $field, $value, $entry_id, $form_id ) {
- 5.
if (strpos($_GET['client_email'], "@client2.com") > -1) {
- 6.
$field->visibility = "visible";
- 7.
}
- 8.
}
- 9.
- 10.
//More generic alteration on gform_pre_render, on specifically form ID 6
- 11.
add_filter( 'gform_pre_render_6', 'my_other_function' );
- 12.
- 13.
function my_other_function( $form ) {
- 14.
if (strpos($_GET['client_email'], "@client2.com") > -1) { // <- you can change the haystack/needle
- 15.
foreach($form->fields as $field) {
- 16.
if ($field->id = 123) { // <- change the id of the field you want here
- 17.
$field->visibility = "visible";
- 18.
}
- 19.
}
- 20.
}
- 21.
}
- 22.