• 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.
     
// apply to a specific form ID 6 and field ID 123 add_filter( 'gform_field_input_6_123', 'my_custom_function', 10, 5 ); function my_custom_function( $input, $field, $value, $entry_id, $form_id ) { if (strpos($_GET['client_email'], "@client2.com") > -1) { $field->visibility = "visible"; } } //More generic alteration on gform_pre_render, on specifically form ID 6 add_filter( 'gform_pre_render_6', 'my_other_function' ); function my_other_function( $form ) { if (strpos($_GET['client_email'], "@client2.com") > -1) { // <- you can change the haystack/needle foreach($form->fields as $field) { if ($field->id = 123) { // <- change the id of the field you want here $field->visibility = "visible"; } } } }

Copy Code to Clipboard Raw

Sign-in or Create a Free Account.

Snippi uses Twitter or Facebook to register and create accounts. Registration will enable you to keep track of your snippets. We never spam your timeline or wall. Ever.

Sign-in with Facebook Sign-in with Twitter