Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'gform_after_submission_1', 'post_contact_info', 10, 2 );
- function post_contact_info( $entry, $form ) {
- $user = 'xxxxx';
- $pass = 'uuuuu';
- $url = 'https://API.EposnowHQ.com/API/V2/Customer/';
- $headers = array(
- 'Content-Type' => 'application/json',
- 'Authorization' => 'Basic '. base64_encode("$user:$pass")
- );
- $contact_info = array(
- 'Forename' => $entry['53'],
- 'Surname' => $entry['55'],
- 'ContactNumber' => $entry['5'],
- 'EmailAddress' => $entry['4']
- );
- $body = json_encode( $contact_info );
- $args = array( 'headers' => $headers, 'body' => $body );
- $response = wp_remote_post( esc_url_raw( $url ), $args );
- $response_code = wp_remote_retrieve_response_code( $response );
- $response_body = wp_remote_retrieve_body( $response );
- $result = json_decode( $response_body );
- $customer_id = $result['CustomerID'];
- $address_info = array(
- 'CustomerID' => $customer_id,
- 'AddressLine1' => $entry['35'],
- 'Town' => $entry['36'],
- 'State' => $entry['38'],
- 'PostCode' => $entry['39']
- );
- $url2 = 'https://API.EposnowHQ.com/API/V2/CustomerAddress/';
- $body2 = json_encode( $address_info );
- $args2 = array( 'headers' => $headers, 'body' => $body2 );
- $response2 = wp_remote_post( esc_url_raw( $url2 ), $args2 );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement