Advertisement
verygoodplugins

Untitled

Feb 28th, 2019
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.61 KB | None | 0 0
  1. function wpf_ontraport_field( $args ) {
  2.  
  3.     if( ! function_exists( 'wp_fusion' ) ) {
  4.         return;
  5.     }
  6.  
  7.     $contact_id = wp_fusion()->user->get_contact_id();
  8.  
  9.     if( empty( $contact_id ) ) {
  10.         return false;
  11.     }
  12.  
  13.     $params = wp_fusion()->crm->get_params();
  14.  
  15.     $url      = "https://api.ontraport.com/1/object?objectID=0&id=" . $contact_id;
  16.     $response = wp_remote_get( $url, $params );
  17.  
  18.     $body_json = json_decode( $response['body'], true );
  19.  
  20.     if( isset( $body_json['data'][ $args['field'] ] ) ) {
  21.         return $body_json['data'][ $args['field'] ];
  22.     }
  23.  
  24. }
  25.  
  26. add_shortcode( 'wpf_ontraport_field', 'wpf_ontraport_field' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement