Hi
On this site adszoom . com we are using a form on a page that uses header and footer. The form has 4 image uploads to it and but the issue is happening with or without the photos. Its taking 90 seconds to process. Here is the code im using for the form I don’t know why its taking so long but on the avg. I get 2 support tickets saying that the wheel keeps spinning.
Any idea?
<?php add_action('gform_pre_render_2', 'gform_limit_submissions');
function gform_limit_submissions($form){
global $wpdb;
$limit_message = '<strong>Oops!</strong> You may only submit a new classified ad<br /> every 5 minutes and a total of 25 every 24 hours.<br /> You may want to read <br />(<em> Posting your ads in high competition topics ....</em> ) <br /> under (<em> Help / Edit Ads</em> ) tab above as you wait.<br /> Your last ads keywords selection should have bin <br /> chosen with pinpoint topic accuracy after reading<br /> this. Doing this step will make you money by<br /> putting your ads on page 1# of all search engines!<br /> <strong>Note:</strong> If you post something in the <strong>wrong</strong><br /> category<br /> for example: a ( <em>house for rent</em> ) in
( <em>services</em>),<br /> it will be <strong>deleted</strong> without warning within reason.<br /> You may also post <strong>duplicate</strong> ads but change the <br />title and keywords each time so its rated as<br /> ( <em>new content</em> ). <br /><br /><br /><br /><br />
<strong>Thank you</strong> for your patients as we review your last<br /> classified ad.<br /> Less then 3 minutes to go!';
$limit_time = 300; // must be specified in seconds; 86400 seconds is equal to 24 hours
/* You do not need to edit below this line */
$current_user = wp_get_current_user();
$last_submission = $wpdb->get_var($wpdb->prepare("SELECT date_created FROM {$wpdb->prefix}rg_lead WHERE created_by = %d and form_id = %d ORDER BY date_created DESC", $current_user->ID, $form['id']));
if(empty($last_submission))
return $form;
$time_out = strtotime($last_submission) + $limit_time;
$current_time = time();
if($current_time > $time_out)
return $form;
$is_submit = rgpost("is_submit_{$form['id']}");
if(!$is_submit) {
add_filter('gform_get_form_filter', create_function('', "return '<div class=\"limit-message\">$limit_message</div>';") );
}
return $form;
}
?>
<?php
add_filter('gform_validation_2', 'title_length');
function title_length($validation_result){
$form = $validation_result["form"];
//supposing we don't want input_1 to be longer than 100 characters.
if(strlen($_POST['input_1']) > 100){
// set the form validation to false
$validation_result["is_valid"] = false;
//finding Field with ID of 1 and marking it as failed validation
foreach($form["fields"] as &$field){
//NOTE: replace 1 with the field you would like to validate
if($field["id"] == "1"){
$field["failed_validation"] = true;
$field["validation_message"] = "Your title is too long 100 characters Google max";
break;
}
}
}
//Assign modified $form object back to the validation result
$validation_result["form"] = $form;
return $validation_result;
}
?>
<?php
add_filter('gform_validation_2', 'tags_length');
function tags_length($validation_result){
$form = $validation_result["form"];
//supposing we don't want input_1 to be longer than 100 characters.
if(strlen($_POST['input_8']) > 100){
// set the form validation to false
$validation_result["is_valid"] = false;
//finding Field with ID of 1 and marking it as failed validation
foreach($form["fields"] as &$field){
//NOTE: replace 1 with the field you would like to validate
if($field["id"] == "8"){
$field["failed_validation"] = true;
$field["validation_message"] = "<strong>100 words and spaces.</strong> Please only use a handful of pinpointed keywords. You do not need many, just pick the ones that are pinpoint. For example: If your title is ( <em>Tile floor cleaning</em> ) do not used keywords like ( <em>carpet cleaning</em> ) You will <strong>confuse the search engines.</strong> Post separate ads for each service or item your offering. See ( <em>Things to know before you post</em> ) here to the right in yellow for more info.";
break;
}
}
}
//Assign modified $form object back to the validation result
$validation_result["form"] = $form;
return $validation_result;
}
?>
<?php
add_filter('gform_validation_2', 'email_length');
function email_length($validation_result){
$form = $validation_result["form"];
//supposing we don't want input_1 to be longer than 100 characters.
if(strlen($_POST['input_11']) > 50){
// set the form validation to false
$validation_result["is_valid"] = false;
//finding Field with ID of 1 and marking it as failed validation
foreach($form["fields"] as &$field){
//NOTE: replace 1 with the field you would like to validate
if($field["id"] == "11"){
$field["failed_validation"] = true;
$field["validation_message"] = "<strong>50 word and spaces max.</strong>.";
break;
}
}
}
//Assign modified $form object back to the validation result
$validation_result["form"] = $form;
return $validation_result;
}
?>
<?php
add_filter('gform_validation_2', 'companies_length');
function companies_length($validation_result){
$form = $validation_result["form"];
//supposing we don't want input_1 to be longer than 100 characters.
if(strlen($_POST['input_17']) > 50){
// set the form validation to false
$validation_result["is_valid"] = false;
//finding Field with ID of 1 and marking it as failed validation
foreach($form["fields"] as &$field){
//NOTE: replace 1 with the field you would like to validate
if($field["id"] == "17"){
$field["failed_validation"] = true;
$field["validation_message"] = "<strong>50 word and spaces max.</strong>.";
break;
}
}
}
//Assign modified $form object back to the validation result
$validation_result["form"] = $form;
return $validation_result;
}
?>
<?php
add_filter('gform_validation_2', 'contact_name_length');
function contact_name_length($validation_result){
$form = $validation_result["form"];
//supposing we don't want input_1 to be longer than 100 characters.
if(strlen($_POST['input_18']) > 50){
// set the form validation to false
$validation_result["is_valid"] = false;
//finding Field with ID of 1 and marking it as failed validation
foreach($form["fields"] as &$field){
//NOTE: replace 1 with the field you would like to validate
if($field["id"] == "18"){
$field["failed_validation"] = true;
$field["validation_message"] = "<strong>50 word and spaces max.</strong>.";
break;
}
}
}
//Assign modified $form object back to the validation result
$validation_result["form"] = $form;
return $validation_result;
}
?>
<?php
add_filter('gform_validation_2', 'web_address_length');
function web_address_length($validation_result){
$form = $validation_result["form"];
//supposing we don't want input_1 to be longer than 100 characters.
if(strlen($_POST['input_19']) > 50){
// set the form validation to false
$validation_result["is_valid"] = false;
//finding Field with ID of 1 and marking it as failed validation
foreach($form["fields"] as &$field){
//NOTE: replace 1 with the field you would like to validate
if($field["id"] == "19"){
$field["failed_validation"] = true;
$field["validation_message"] = "<strong>50 word and spaces max.</strong>.";
break;
}
}
}
//Assign modified $form object back to the validation result
$validation_result["form"] = $form;
return $validation_result;
}
?>