Таким образом вы получаете запрос контактной формы 7
add_filter( 'wpcf7_mail_components', 'show_cf7_request', 10, 3 );
function show_cf7_request( $components, $wpcf7_get_current_contact_form, $instance ) {
post_to_another_url('https://site-to.post', $_REQUEST);
return $components;
};
и пересылаете идентификатор на другой URL-адрес в виде JSON POST
function post_to_another_url($url, $data {
if(is_array($data) && $url != '') {
// copied from => https://tecadmin.net/post-json-data-php-curl/
$payload = json_encode($data);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
// Set HTTP Header for POST request
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($payload))
);
// Submit the POST request
$result = curl_exec($ch);
// Close cURL session handle
curl_close($ch);
}
}
, если хотите вставить данные в одну и ту же базу данных, но разныестол, используйте $wpdb->insert()
https://developer.wordpress.org/reference/classes/wpdb/insert/