Use the Gravity Forms API to Modify A Value Based on Other User Input

add_action( 'gform_pre_submission_1', 'change_a_field_value_using_other_fields' );

function change_a_field_value_using_other_fields( $form ) {


$a_field_in_your_form = rgpost( 'input_YOUR-FIELD-ID' );

switch ($a_field_in_your_form) {

    //Concatenate, Change or Calculate a new value

    case 0:
       $_POST['input_THE-FIELD-ID-YOU-WANT-TO-CHANGE'] = "$_POST['input_THE-FIELD-ID-YOU-WANT-TO-CHANGE']" . "(" . $a_field_in_your_form . ")";
        break;
    case 1:
       $_POST['input_THE-FIELD-ID-YOU-WANT-TO-CHANGE'] = "A NEW VALUE BASED ON 1";
        break;
    case 2:
        $_POST['input_THE-FIELD-ID-YOU-WANT-TO-CHANGE'] = "A NEW VALUE BASED ON 2";
        break;
}

}

Leave a Reply

Your email address will not be published. Required fields are marked *