Update Hubspot Properties using WordPress PHP Functions and the Hubspot API

function update_hubspot_user($user,$token){

    $email = $user->user_email;
      
    $hubspot_properties = array(

        'email' => $email,
        'some_property' => 'some_value'
    
    );

    $props = array('properties'=>$hubspot_properties);

    $request_url = 'https://api.hubapi.com/crm/v3/objects/contacts/' . $email . '?idProperty=email';

    $args = array(

        'headers' => array(
            
            'Authorization' => 'Bearer ' . $token,

            'Content-Type'  => 'application/json',

        ),

        'method' => 'PATCH',

        'body' => json_encode($props)

    );

    $response = wp_remote_request( $request_url, $args );
        
}

One thought on “Update Hubspot Properties using WordPress PHP Functions and the Hubspot API

Leave a Reply

Your email address will not be published. Required fields are marked *