Hi all,
Is it possible to track the submission’s ip and location with bricks form? If yes, how?
Thanks in advance.
Hi all,
Is it possible to track the submission’s ip and location with bricks form? If yes, how?
Thanks in advance.
Hello.
I can suggest the following solution
function bricks_form( $form ){
$data = $form->get_fields();
$fields = $form->get_fields();
$formId = $fields['formId'];
$postId = $fields['postId'];
$settings = $form->get_settings();
$files = $form->get_uploaded_files();
$request = file_get_contents("https://api.sypexgeo.net/yourmeaning/json/".$_SERVER['REMOTE_ADDR']);
$array = json_decode($request);
$city_name = $array->city->name_en;
$IP=$array->ip;
// The Bricks Form ID is the last part of the CSS ID
// So if a form has a CSS ID of bricks-element-fszxsr, then the form ID is fszxsr
$formId = $data['formId'];
$current_user_id = get_current_user_id();
// Replace this comment with the description of the form
// Copy and paste the IF block below to add custom action for other forms
if( $formId == 'dniefh' ){
$current_user_id = get_current_user_id();
$user_id = wp_update_user( [
'ID' => $current_user_id,
'first_name' => $data['form-field-c2b2c7'],
'last_name' => $data['form-field-7b5ca1'],
'acf-field_63ceebe2ebe39' => $data['form-field-yedlwj'],
'acf-field_6405b46ee2da4' => $data['form-field-dxqmhd']['0'],
] );
$subject = 'Test '.$IP;
$message = print_r($array, true);
wp_mail('test@email.com', $subject, $message);
}
}
add_action( 'bricks/form/custom_action', 'bricks_form', 10, 1 );
There are many options for obtaining visitor data, basically all APIs are paid if you want to receive advanced data