/** * Copy existing profile fields to * new profile from the already built profile * * @param int $old_id * From which we need to copy. * @param bool $new_id * In which to copy. * * @return void */ public static function copy($old_id, $new_id) { $ufField = new CRM_Core_DAO_UFField(); $ufField->uf_group_id = $old_id; $ufField->find(); while ($ufField->fetch()) { //copy the field records as it is on new ufgroup id $ufField->uf_group_id = $new_id; $ufField->id = NULL; $ufField->save(); } }