Troubles getting data from form

Home Forums Quform WordPress Troubles getting data from form

This topic is: resolved
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #12052
    pczjrh
    Participant

    Okay, 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. :-/
    }

    #12053
    pczjrh
    Participant

    I’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';
    }

    #12066
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #12115
    pczjrh
    Participant

    Hi 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.

    #12136
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #12155
    pczjrh
    Participant

    The 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.
    #12178
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #12196
    pczjrh
    Participant

    Got it working. Thanks, you were right, it wasn’t the ID of the form field!

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2025 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy