0
votes

I'd like to send a file to everyone who gets my webform. This should be a hidden file that the person filling in the form doesn't need to attach but the receiver gets. Its for a job advert that someone fills in a request and then they get sent back a 'Thanks' message and they are asked to fill in a word document about equal opportunities.

I guess its probably doable with webform rules but I'm not getting any luck with that.

1

1 Answers

0
votes

Write a custom module with hook_form_alter implementation, and add a custom submission callback to handle the file attachment.

This way you can handle form fields and values, before the webform values getting saved in database or getting sent via email.

Code sample:

function MODULE_form_alter(&$form, &$form_state, $form_id) {
    if($form_id === 'YOUR_FORM_ID') {
        // code as needed in here :)
        // add another submission callback
        $form['submit'][] = 'YOUR_NEW_FORM_SUBMISSION_CALLBACK';
    }
}

function YOUR_NEW_FORM_SUBMISSION_CALLBACK($form, &$form_state) {
    // code as needed here
}