I just started with Gravity Forms. I currently setting up a form with the following problem: For setting up a company you must pay in at least USD 10 and at least 10% of the nominal capital. Therefore, there are 3 cases where the requirements are not met:
(1) Paid in capital is less than USD 10
(2) Paid in capital is less than 10% of the nominal capital
(3) Paid in capital is less than USD 10 and 10% of the nominal capital.
if ( $result['is_valid'] && intval( $value ) < 10) {
$result['is_valid'] = false;
$result['message'] = 'The paid in capital must at least amount to USD 10';
}
return $result;
}
How can I add the two other if-clauses (i figured out, that i need elseif clauses)? The nominal capital is a form field, which can be determined by the user. It would be best if I could take the number from the nominal-capital field an multiply it by 10% and than compare it with “<” with my paid in capital field.
if ( $result['is_valid'] ( $value ) < 10 ) {
$result['is_valid'] = false;
$result['message'] = 'Paid in capital is less than USD 10';
}
elseif ( $result[‘is_valid’] < $post_value) {
$result[‘is_valid’] = false;
$result[‘message’] = ‘Paid in capital is less than 10% of the nominal capital’;
}
elseif ( $result[‘is_valid’] < $post_value && $result[‘is_valid’] < 10) {
$result[‘is_valid’] = false;
$result[‘message’] = ‘Paid in capital is less than USD 10 and 10% of the nominal capital’;
}
Your system’s error log will tell you exactly what the actual critical error is, you can also enable debugging in WordPress to see it: Debugging in WordPress | WordPress.org
Just at first glance at your code, you’re supplying too many arguments within the callback function on line 2. You should only have $result, $value, $form, and $field there.