$this->buildCustom($this->_values['custom_pre_id'], 'customPre', TRUE);
$this->buildCustom($this->_values['custom_post_id'], 'customPost', TRUE);
- if (!empty($params['onbehalf'])) {
+ if (!empty($this->_values['onbehalf_profile_id']) &&
+ !empty($params['onbehalf']) &&
+ ($this->_values['is_for_organization'] == 2 ||
+ !empty($params['is_for_organization'])
+ )
+ ) {
$fieldTypes = array('Contact', 'Organization');
$contactSubType = CRM_Contact_BAO_ContactType::subTypes('Organization');
$fieldTypes = array_merge($fieldTypes, $contactSubType);