• Resolved badro0

    (@badro0)


    Hello,

    I’m using the plugin to create a job application form. My form contains a resume field wich is a file field.
    I need to get the submitted data, so i’m using the ‘wpcf7_posted_data’ hook like this:

    // define the wpcf7_posted_data callback 
    function filter_wpcf7_posted_data( $posted_data ) { 
        die(var_dump($posted_data));
        return $posted_data; 
    }; 
             
    // add the filter 
    add_filter( 'wpcf7_posted_data', 'filter_wpcf7_posted_data', 10, 1 );

    Actually i’m getting all the data except the files. Is there something i’m missing or is it not possible ?

    Thank you!

    • This topic was modified 6 years, 5 months ago by badro0.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Takayuki Miyoshi

    (@takayukister)

    The wpcf7_posted_data filter hook has no connection with uploaded files. Uploaded files are in the uploaded_files property, not in the posted_data property.

    Thread Starter badro0

    (@badro0)

    Awesome!
    They are in WPCF7_Submission class.
    Here is the code if anyone is interested:

    // define the wpcf7_before_send_mail callback 
    function action_wpcf7_before_send_mail( $contact_form ) { 
        $id = $contact_form->id();
        if ($id==128){
            $submission = WPCF7_Submission::get_instance();
            $posted_data = $submission->get_posted_data();
            $uploaded_files = $submission->uploaded_files();
            //Process files and data
        }
    }; 
             
    // add the action 
    add_action( 'wpcf7_before_send_mail', 'action_wpcf7_before_send_mail', 10, 1 );

    Thanks!

    • This reply was modified 6 years, 5 months ago by badro0. Reason: improved code
    • This reply was modified 6 years, 5 months ago by badro0.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Trying to capture posted data’ is closed to new replies.