function send_data_to_django_on_register( $user_id ) {
echo '(registration hook2)';
// Get the user data
$user = get_userdata( $user_id );
// print_r ($user);
// Build the data to send to the Django API
$api_data = array(
'username' => $user->user_login,
'email' => $user->user_email,
);
// print_r ($api_data);
// $plugin_name = "WORDPRESS ".$this->getWordpressVersion();
// URL of the Django API endpoint
$api_url = 'http://192.168.1.13:8000/merchant/loyalty_Plugin/';
// Make the POST request to the Django API
$response = wp_remote_post( $api_url, array(
'body' => $api_data
) );
print_r ("<---Responce--->",$response);
// Check if the request was successful
if ( is_wp_error( $response ) ) {
return false;
}
// Decode the JSON data returned by the Django API
$data = json_decode( wp_remote_retrieve_body( $response ), true );
print_r ("<---Data--->",$data);
$plugin_name = "WORDPRESS ".$this->getWordpressVersion();
}
add_action( 'user_register', 'send_data_to_django_on_register' );