verygoodplugins

Untitled

Feb 6th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.30 KB | None | 0 0
  1. function store_additional_license_parameters($response, $args, $license_id) {
  2.  
  3.     $data = $_REQUEST;
  4.  
  5.     if($response['license'] == 'valid' && !empty($data['crm'])) {
  6.  
  7.         $user = get_user_by('email', $response['customer_email']);
  8.         update_user_meta($user->ID, 'active_crm', $data['crm']);
  9.  
  10.         update_user_meta( $user->ID, 'last_license_check', date('m/d/Y') );
  11.  
  12.         if( isset($data['integrations']) && is_array( $data['integrations'] ) ) {
  13.             update_user_meta($user->ID, 'active_integrations', implode(', ', $data['integrations']));
  14.         }
  15.  
  16.         $contact_id = wp_fusion()->user->get_contact_id($user->ID);
  17.  
  18.         $update_data = array(
  19.             'email'         => $user->user_email,
  20.             'field[17,0]'   => $data['crm'],
  21.             'field[20,0]'   => date('m/d/Y')
  22.             );
  23.  
  24.         if( isset($data['integrations']) && is_array( $data['integrations'] ) ) {
  25.             $update_data['field[19,0]'] = '||' . implode('||', $data['integrations']) . '||';
  26.         }
  27.  
  28.         if( isset( $data['version'] ) ) {
  29.             update_user_meta($user->ID, 'wpf_version', $data['version'] );
  30.         }
  31.  
  32.         wp_fusion()->crm->update_contact($contact_id, $update_data, false);
  33.  
  34.     }
  35.  
  36.     return $response;
  37.  
  38. }
  39.  
  40. add_filter( 'edd_remote_license_check_response', 'store_additional_license_parameters', 10, 3);
  41. add_filter( 'edd_remote_license_activation_response', 'store_additional_license_parameters', 10, 3);
Add Comment
Please, Sign In to add comment