Home › Forums › Quform WordPress › Troubles getting data from form
- This topic has 7 replies, 2 voices, and was last updated 11 years ago by
pczjrh.
- AuthorPosts
- August 3, 2014 at 4:22 pm #12052
pczjrh
ParticipantOkay, so having read the forums and followed the example code, I can not get this working.
I know I’m writing in the right place as the MAIL() command sends mail fine – I’ve commented what happens in each bit of code.What I would like to do is create folders based on a drop down box logical expression and also rename the file from multiple inputs from the form, and save it to that custom folder
I have 1 form with ID=1.
$filename = apply_filters('iphorm_upload_filename', $filename, $element);
$filename = apply_filters("iphorm_upload_filename_$formId", $filename, $element);
function my_post_process($form)
{
$value = $form->getValue('iphorm_1_8');
mail('myaddress@mydomain.com', 'PHP Mail Test', 'Test Message from PHP returning value of - '.$value, 'From: webmaster@example.com');
}
add_action('iphorm_post_process_1', 'my_post_process');
//This works fine and returns the value from the form ;-)add_filter('iphorm_upload_filename_1', 'mytheme_form_upload_filename', 10, 2);
function mytheme_form_upload_filename($form)
{
$league = $form->getValue('iphorm_1_8');
return "League_".$league."_TestImage.jpg";
}
//This does not rename the file using the same extracted value. :-(add_filter('iphorm_upload_path', 'my_upload_path');
function my_upload_path($form)
{$league = $form->getValue('iphorm_1_8');
return '/PDI_uploads/';
//This also does;t create folders based on a name, but will create new folders if I hard code them in this function. :-/
}
August 3, 2014 at 8:15 pm #12053pczjrh
ParticipantI’ve been playing with the functions section to see where the problem is.
It seems that even interacting with the form in any way causes an error.
Why should this be the case? Here the variable I create has nothing to do with the return, yet it causes an error!
add_filter('iphorm_upload_path', 'my_upload_path');
function my_upload_path($path, $element)
{
$league = $element->getForm()->getValue('iphorm_1_8');
return '/PDI_uploads';
}
August 4, 2014 at 8:47 pm #12066Ally
Support StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
August 8, 2014 at 11:46 pm #12115pczjrh
ParticipantHi Ally,
I’ve been trying with you resample functions, and I can get the directory my-Uploads_path() to work fine with my form.
However, I am having no jy with the file renaming function example you provided me.
Here is my code. The iphorm names are correct and I only have 1 form with id=1.
$newfilename = apply_filters('mytheme_form_upload_filename', $filename, $element,$form);
add_filter('iphorm_filename_iphorm_1_1', 'mytheme_form_upload_filename', 10, 3);
function mytheme_form_upload_filename($filename, $element, $form)
{
$league = $element->getForm()->getValue('iphorm_1_8');
if ($league == 'League 1'){
$clubID = $element->getForm()->getValue('iphorm_1_9');
}
if ($league == 'League 2'){
$clubID = $element->getForm()->getValue('iphorm_1_17');
}
if ($league == 'League 3'){
$clubID = $element->getForm()->getValue('iphorm_1_18');
}
if ($league == 'League 4'){
$clubID = $element->getForm()->getValue('iphorm_1_12');
}
if ($league == 'League 5'){
$clubID = $element->getForm()->getValue('iphorm_1_13');
}
if ($league == 'League 6'){
$clubID = $element->getForm()->getValue('iphorm_1_14');
}
if ($league == 'League 6'){
$clubID = $element->getForm()->getValue('iphorm_1_15');
}
$imagenumber=$element->getForm()->getValue('iphorm_1_6');
$imagetitle=$element->getForm()->getValue('iphorm_1_1');
$author=$element->getForm()->getValue('iphorm_1_2');
$length=10;
$min = pow(10, $length - 1);
$max = pow(10, $length) - 1;
$randNum=mt_rand($min, $max);
$newfilename=$clubID.$imagenumber.'_'.$imagetitle.'_'.$author.'_'.$randNum.'.jpg';
return $newfilename;
}
Can you tell me why this isn’t working?
Thanks,
Jason.August 11, 2014 at 12:09 pm #12136Ally
Support StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
August 11, 2014 at 7:33 pm #12155pczjrh
ParticipantThe file isn’t renamed. Other than this the directory is created, the site responds with a positive upload confirmation, the file is entered into the DB as expected.
I’m on the latest version 1.4.17, so no problems there.
I’ve enabled debugging, and after getting errors from the first line$newfilename = apply_filters(‘mytheme_form_upload_filename’, $filename, $element,$form);
I removed it. There are no errors from the functions.php file after this. I do get some regarding ad-square, but nothing to do with this process.
The function isn’t being called at all. This code does nothing to the filename
add_filter('iphorm_filename_iphorm_1_1', 'mytheme_form_upload_filename', 10, 3);
function mytheme_form_upload_filename($filename, $element, $form)
{
return 'file.jpg';
}
which should if I’m correct rename all files uploaded as ‘file.jpg’Any further help would be appreciated, as I need to get this up and running. I’m on a deadline now.
Thanks again,
Jason.- This reply was modified 11 years ago by
pczjrh.
August 14, 2014 at 1:18 pm #12178Ally
Support StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
August 16, 2014 at 5:52 pm #12196pczjrh
ParticipantGot it working. Thanks, you were right, it wasn’t the ID of the form field!
- This reply was modified 11 years ago by
- AuthorPosts
- You must be logged in to reply to this topic.