verygoodplugins

Untitled

May 1st, 2020
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.69 KB | None | 0 0
  1. function wpf_add_note_to_nationbuilder( $entry, $form ) {
  2.  
  3.     if ( ! function_exists( 'wp_fusion' ) ) {
  4.         return;
  5.     }
  6.  
  7.     $contact_id = gform_get_meta( $entry['id'], 'wpf_contact_id' );
  8.  
  9.     if ( ! empty( $contact_id ) ) {
  10.  
  11.         $params = wp_fusion()->crm->get_params();
  12.  
  13.         $body = array(
  14.             'note' => array(
  15.                 'content' => $entry['4'],
  16.             ),
  17.         );
  18.  
  19.         $params['body'] = json_encode( $body );
  20.  
  21.         $request  = 'https://' . wp_fusion()->crm->url_slug . '.nationbuilder.com/api/v1/people/' . $contact_id . '/notes/?access_token=' . wp_fusion()->crm->token;
  22.         $response = wp_remote_post( $request, $params );
  23.  
  24.     }
  25.  
  26. }
  27.  
  28. add_action( 'gform_after_submission', 'wpf_add_note_to_nationbuilder', 10, 2 );
Add Comment
Please, Sign In to add comment