vendredi 14 décembre 2018

PHP Multiple elseif statments

I'm using Gravity Forms integrated with Zoho CRM, and I'm having trouble getting Google AdWords information sent to Zoho. I'm supposed to add the following snippet for a hidden field I've added to a form.

add_filter( "gform_field_input", "zoho_tracker", 10, 5 );
function zoho_tracker( $input, $field, $value, $lead_id, $form_id ) {
// because this will fire for every form/field, only do it when it is the specific form and field
if ($form_id == 3 && $field["id"] == 17){
    $input = '<input type="hidden" id="zc_gad" name="zc_gad" value="">';    
}
   return $input;
}

I have multiple form/field id's, so I want to confirm if the following snippet is correct:

// Zoho hidden Gravity Form fields
add_filter( "gform_field_input", "zoho_tracker", 10, 5 );
function zoho_tracker( $input, $field, $value, $lead_id, $form_id ) {
// because this will fire for every form/field, only do it when it is the specific form and field
if ($form_id == 3 && $field["id"] == 17){
    $input = '<input type="hidden" id="zc_gad" name="zc_gad" value="">';
        }
    elseif ($form_id == 12 && $field["id"] == 17){
    $input = '<input type="hidden" id="zc_gad" name="zc_gad" value="">';
        }
    elseif ($form_id == 6 && $field["id"] == 13){
    $input = '<input type="hidden" id="zc_gad" name="zc_gad" value="">';
        }
    elseif ($form_id == 1 && $field["id"] == 19){
    $input = '<input type="hidden" id="zc_gad" name="zc_gad" value="">';
        }
    elseif ($form_id == 3 && $field["id"] == 16){
    $input = '<input type="hidden" id="zc_gad" name="zc_gad" value="">';
        }
    elseif ($form_id == 11 && $field["id"] == 42){
    $input = '<input type="hidden" id="zc_gad" name="zc_gad" value="">';
        }
    elseif ($form_id == 8 && $field["id"] == 42){
    $input = '<input type="hidden" id="zc_gad" name="zc_gad" value="">';
        }
    elseif ($form_id == 9 && $field["id"] == 24){
    $input = '<input type="hidden" id="zc_gad" name="zc_gad" value="">';
        }
    elseif ($form_id == 13 && $field["id"] == 38){
    $input = '<input type="hidden" id="zc_gad" name="zc_gad" value="">';
        }
    else {
}
   return $input;
}

Aucun commentaire:

Enregistrer un commentaire