How to send user data in json format to another server when user register on wordpress site in PHP. I have a server url is like (http://1.2.3.4:49005/SingleMethodName=DomainManagementStripeService___DomainRegistration)
when user register on wordpress site i want to send their name, email, custom fields data to my server in json format. Thanks
Edited----- I am using mu-plugins for this purpose and bellow is the code i am using it for
<?php
add_action('init', 's2_payment_notification');
function s2_payment_notification()
{
if( isset($_POST['user_id'], $_POST['subscr_id'], $_POST['user_ip'],$_POST['user_piva']))
{
$user_id = (integer)$_POST['user_id'];
$subscr_id = (string)$_POST['subscr_id'];
$user_ip = (string)$_POST['user_ip'];
$user_piva = (integer)$_POST['user_piva'];
$s2member_subscr_id = get_user_option('s2member_subscr_id', $user_id);
$s2member_registration_ip = get_user_option('s2member_registration_ip', $user_id);
$s2member_p_iva_fisc = get_user_option('p_iva_fisc', $user_id);
$user_piva = wp_json_encode($s2member_p_iva_fisc);
$user_ip = wp_json_encode($s2member_registration_ip);
$subscr_id = wp_json_encode($s2member_subscr_id);
wp_remote_post('http://1.2.3.123:49005/SingleMethodName=DomainManagementStripeService___DomainRegistration', [
'headers' => ['content-type' => 'application/json'],
'body' => array(
'User_Id' => '$user_id',
'subscr_id' => '$subscr_id',
'user_ip' => '$user_ip',
'user_piva' => '$user_piva'
),
]);
}
else {
wp_remote_post('http://1.2.3.123:49005/SingleMethodName=DomainManagementStripeService___DomainRegistration', [
'headers' => ['content-type' => 'application/json'],
'body' => 'Everything is empty',
]);
}
}
user_register
hook. Usecurl
orfile_get_contents
to ping your server with the user info.