I want to populate dynamic data into a field in gravity form from function.php before form submissions. but my code below is not working.
My code/steps not working:
I am marking a gravity form field "Allow field to be populated dynamically" and giving a parameter name "time" So I can use it as a hook in function.php. Please see the screenshot https://snag.gy/AGQ8CU.jpg
and then, in my function.php, I am using this code to calculate current's time and passing it back to the form so the form can submit current time.
The code in function.php:
$timespam = "";
add_filter( 'gform_field_value_timestamp', 'timestamp_population_function');
function timestamp_population_function() {
$timespam = time();
return $timespam;
}
But my code is not working and not taking dynamic time from functions.php and sending current time.
I also want to re-use this dynamic value in a different function and also want to load another form's field value in below function. Such as:
add_filter( 'gform_field_value_hash', 'hash_population_function' );
function hash_population_function($value) {
$x_amount = $_POST['input_26']; // I am trying to get value from form's field
$hmac_data = $timespam . "^" . $x_amount;
$x_fp_hash = hash_hmac('MD5', $hmac_data, $transaction_key);
return $x_fp_hash;
}
Can you please check if my code/steps are good? or is there any other way to achieve it?