如何在Wordpress中通过cURL PHP提交自定义POST表单

I'm making a theme wordpress use childtheme in localhost. I had a basic form html in footer.php:

<form method="post">     
    <input name="FNAME" type="text">
    <input name="LNAME" type="text">
    <input name="EMAIL" type="email">
    <button type="submit">Subscribe</button>
</form>

现在,我想通过cURL php将表单提交到api url。我知道设置cURL的代码是这样的:

$data =  $_POST;

$curl = curl_init();

$options =array(
    CURLOPT_RETURNTRANSFER =>true,
    CURLOPT_URL => 'link_to_url',
    CURLOPT_POST => true,
    CURLOPT_CONNECTTIMEOUT => 30,
    CURLOPT_USERAGENT => "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)",
    CURLOPT_SSL_VERIFYPEER => false,
    CURLOPT_POSTFIELDS => http_build_query($data)
);
curl_setopt_array($curl, $options);

$result = curl_exec($curl);
curl_close($curl);

I want to when form is submitted , POST data will send via this cURL, But I don't know where I should place this code and how to process it. I think it maybe placed in a function in function.php but I don't know how to write it .Please help me!