/** * Delete profile field given a custom field. * * @param int $customFieldId * ID of the custom field to be deleted. * * @return void * */ public static function delUFField($customFieldId) { //find the profile id given custom field id $ufField = new CRM_Core_DAO_UFField(); $ufField->field_name = "custom_" . $customFieldId; $ufField->find(); while ($ufField->fetch()) { //enable/ disable profile CRM_Core_BAO_UFField::del($ufField->id); } }
/** * Delete the profile Group. * * @param int $id * Profile Id. * * @return bool * */ public static function del($id) { //check whether this group contains any profile fields $profileField = new CRM_Core_DAO_UFField(); $profileField->uf_group_id = $id; $profileField->find(); while ($profileField->fetch()) { CRM_Core_BAO_UFField::del($profileField->id); } //delete records from uf join table $ufJoin = new CRM_Core_DAO_UFJoin(); $ufJoin->uf_group_id = $id; $ufJoin->delete(); //delete profile group $group = new CRM_Core_DAO_UFGroup(); $group->id = $id; $group->delete(); return 1; }