Advertisement
verygoodplugins

Untitled

Oct 15th, 2019
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.77 KB | None | 0 0
  1. function my_update_company( $user_id, $contact_id, $user_meta ) {
  2.  
  3.     $company_id = get_user_meta( $user_id, 'hubspot_company_id', true );
  4.  
  5.     if ( empty( $company_id ) ) {
  6.         return;
  7.     }
  8.  
  9.     $data = array(
  10.         'property_one' => 'Value one',
  11.         'property_two' => 'Value two',
  12.     );
  13.  
  14.     $properties = array();
  15.  
  16.     foreach( $data as $property => $value ) {
  17.         $properties[] = array( 'property' => $property, 'value' => $value );
  18.     }
  19.  
  20.     $params           = wp_fusion()->crm->get_params();
  21.     $params['body']   = json_encode( array( 'properties' => $properties ) );
  22.     $params['method'] = 'PUT';
  23.  
  24.     $request  = 'https://api.hubapi.com/companies/v2/companies/' . $company_id;
  25.     $response = wp_remote_post( $request, $params );
  26.  
  27. }
  28.  
  29. add_action( 'wpf_pushed_user_meta', 'my_update_company', 10, 3 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement