Advertisement
verygoodplugins

Untitled

Oct 6th, 2016
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.81 KB | None | 0 0
  1.     /**
  2.      * Update contact
  3.      *
  4.      * @access public
  5.      * @return bool
  6.      */
  7.  
  8.     public function update_contact( $contact_id, $data ) {
  9.  
  10.         if(is_wp_error( $this->connect() ))
  11.             return false;
  12.  
  13.         if(!isset($data['email']))
  14.             $data['email'] = $this->get_email_from_cid($contact_id);
  15.  
  16.         $user_id = wp_fusion()->user->get_user_id( $contact_id );
  17.         $lists = get_user_meta( $user_id, 'activecampaign_lists', true );
  18.  
  19.         if(!empty($lists)) {
  20.  
  21.             foreach((array)$lists as $list_id) {
  22.                 $data['p[' . $list_id . ']'] = $list_id;
  23.             }
  24.  
  25.         } else {
  26.  
  27.             // In case contact has no lists, assume the first list
  28.             $data['p[1]'] = 1;
  29.  
  30.         }
  31.  
  32.         $data['id'] = $contact_id;
  33.  
  34.         $result = $this->app->api( 'contact/edit', $data );
  35.  
  36.         if( $result->success == 1 ) {
  37.  
  38.             return true;
  39.  
  40.         } else {
  41.  
  42.             return false;
  43.  
  44.         }
  45.  
  46.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement