public function delete($useWhere = FALSE) { $id = $this->id; $result = parent::delete($useWhere); try { $custom_params['custom_group_id'] = civicrm_api3('CustomGroup', 'getvalue', array('name' => 'myemma', 'return' => 'id')); $custom_params['name'] = 'my_emmma_' . $id; $custom_field = civicrm_api3('CustomField', 'getsingle', $custom_params); civicrm_api3('CustomField', 'delete', array('id' => $custom_field['id'])); } catch (Exception $e) { //do nothing } return $result; }