id()) { $wpcf7 = WPCF7_ContactForm::get_current(); $submission = WPCF7_Submission::get_instance(); if ($submission) { $data = $submission->get_posted_data(); if (empty($data)) return; // extract posted data for example to get name and change it $firstName = isset($data['first-name']) ? $data['first-name'] : ""; $lastName = isset($data['last-name']) ? $data['last-name'] : ""; $email = isset($data['your-email']) ? $data['your-email'] : ""; $telephone = isset($data['phone-number']) ? $data['phone-number'] : ""; $source = isset($data['heard'][0]) ? $data['heard'][0] : ""; //$RawSourceID = isset($data['_raw_heard']) ? $data['_raw_heard'] : ""; switch ($source) { case "Former client": $sourceID = '9'; break; case "Google": $sourceID = '17'; break; case "Bing": $sourceID = '18'; break; case "Yahoo": $sourceID = '19'; break; case "Facebook": $sourceID = '20'; break; case "LinkedIn": $sourceID = '21'; break; case "Twitter": $sourceID = '22'; break; } $date = date('Y-m-d'); $filePath = 'wp-content/contact-xml' . $fileDirectory; $fileName = random_filename(12, $filePath, 'cl-conx'); $domtree = new DOMDocument('1.0', 'utf-8'); $domtree->formatOutput = true; $xmlRoot = $domtree->createElementNS('http://download.overtech.com.au/schemas/XmlContact.xsd', 'contact'); $xmlRoot = $domtree->appendChild($xmlRoot); $xmlRoot->setAttributeNS(null ,'type', 'individual'); $currentNames = $domtree->createElement('names'); $currentNames = $xmlRoot->appendChild($currentNames); $currentNames->appendChild($domtree->createElement('firstName',$firstName)); $currentNames->appendChild($domtree->createElement('lastName',$lastName)); $currentCommunications = $domtree->createElement('communications'); $currentCommunications = $xmlRoot->appendChild($currentCommunications); $currentCommunications->appendChild($domtree->createElement('email',$email)); if ($telephone!=""){ $currentCommunications->appendChild($domtree->createElement('telephone',$telephone)); } $currentReferral = $domtree->createElement('referral'); $currentReferral = $xmlRoot->appendChild($currentReferral); $currentReferral->appendChild($currentSource = $domtree->createElement('source')); $sourceAttribute = $domtree->createAttribute('id'); $sourceAttribute->value = $sourceID; $currentSource->appendChild($sourceAttribute); $currentProspect = $domtree->createElement('prospect'); $currentProspect = $xmlRoot->appendChild($currentProspect); $prospectAttribute = $domtree->createAttribute('from'); $prospectAttribute->value = $date; $currentProspect->appendChild($prospectAttribute); $currentProspect->appendChild($currentWorkgroup = $domtree->createElement('workgroup')); $workgroupAttribute = $domtree->createAttribute('id'); $workgroupAttribute->value = $workGroupID; $currentWorkgroup->appendChild($workgroupAttribute); $currentTags = $domtree->createElement('tags'); $currentTags = $xmlRoot->appendChild($currentTags); $currentTags->appendChild($domtree->createElement('tag', $tag)); $domtree->save($fileName); // return current cf7 instance return $wpcf7; } } } function random_filename($length, $directory = '', $extension = '') { $dir = !empty($directory) && is_dir($directory) ? $directory : dirname(__FILE__); do { $key = ''; $keys = array_merge(range(0, 9), range('a', 'z')); for ($i = 0; $i < $length; $i++) { $key .= $keys[array_rand($keys)]; } } while (file_exists($dir . '/' . $key . (!empty($extension) ? '.' . $extension : ''))); return $dir . '/' . $key . (!empty($extension) ? '.' . $extension : ''); } // define the wpcf7_is_tel callback function custom_filter_wpcf7_is_tel( $result, $tel ) { $result = preg_match( '/^\({0,1}((0)(2|4|3|7|8)){0,1}\){0,1}(\ |\+|-){0,1}[0-9]{2}(\ |\+|-){0,1}[0-9]{2}(\ |\+|-){0,1}[0-9]{1}(\ |\+|-){0,1}[0-9]{3}$/', $tel ); return $result; } add_filter( 'wpcf7_is_tel', 'custom_filter_wpcf7_is_tel', 10, 2 ); Book now - Birman & Ride

Book now