2

In Drupal 7 using webforms, is there a hook that can alter the outgoing confirmation message shown to someone who has just submitted a form?

enter image description here

My thoughts are to put a text placeholder inside this textarea and do a str_replace to update the output based the submission itself.

2 Answers 2

2

A solution for using submissions value in Submission confirmation message is using Webform Tokens module.

And another solution as you asked is using hook_form_alter add your custom submit handler ( make sure yours getting run before webform's default) change the submitted string with what you want.

4

Like the @zhilevan told you can use hook_form_alter for placeholder and for str_replace you can implement hook_template_preprocess.

Here is an example.

function my_module_preprocess_webform_confirmation(&$vars) {

    $confirmation = check_markup($vars['node']->webform['confirmation'], $vars['node']->webform['confirmation_format'], '', TRUE);
    module_load_include('inc', 'webform', 'includes/webform.submissions');
    $submission = webform_get_submission($vars['node']->nid, $vars['sid']);
    $confirmation = _webform_filter_values($confirmation, $vars['node'], $submission, NULL, FALSE, TRUE);

   // Strip out empty tags added by WYSIWYG editors if needed.
   $vars['confirmation_message'] = strlen(trim(strip_tags($confirmation))) ? $confirmation : '';

}

Source Webform Token support on confirmation message.

you can also take a look on tpl file option. Here webform-confirmation.tpl.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.