Hello,
I"m using cred_save_data to intercept the submit of a form.
add_action('cred_save_data', 'this_save_data_action',10,2);
function this_save_data_action($post_id, $form_data)
{
// if a specific form
if ($form_data['id']==33427)
{
Do somthing code.
}
}
I've got access to $_POST data from prevoius page. but how do I access the field data for the form itself. So say I have a field in the form called "myfield" I can access the $form_data['id'] but is it possible to get the $form_data['myfield']. ?
basically I'm using CURL to send some data to a webhook when the form is submitted.
here's my actual code:
add_action('cred_save_data', 'my_save_data_action',10,2);
function my_save_data_action($post_id, $form_data)
{
// if a specific form
if ($form_data['id']==33414)
{
if (isset($_POST['shared_room_matched']))
{
$curl = curl_init();
$url = '<em><u>hidden link</u></em>';
$myvar1 = $post_id;
$myvar2 = $form_data['myfield'];
$myvars = 'EventID=' . $myvar1 . '&data=' . $myvar2;
$ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_POST, 1);
curl_setopt( $ch, CURLOPT_POSTFIELDS, $myvars);
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt( $ch, CURLOPT_HEADER, 0);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec( $ch );
}
}
}
this works quite well to send the $post_id via myvar1 to the webhook. but I'm wondering how to access the fields data from the form itself.
thanks much++