mymodule_preprocess_webform_confirmation()<\/span>\u00a0.<\/p>\nNext, I wrote the code. In my case it ended up looking something like this:<\/p>\n
\/**\r\n * Implements hook_preprocess_HOOK().\r\n *\/\r\nfunction mymodule_preprocess_webform_confirmation(&$vars) {\r\n if ($vars['webform']->id() == 'rate_workshop') {\r\n $request = \\Drupal::request()->query;\r\n $display_mode = $request->get('display_mode');\r\n $rate_type = $request->get('rate_type');\r\n if ($rate_type === 'complete' && $display_mode === 'overlay') {\r\n $markup = t('Thank you for your feedback.') . '<br\/><br\/>';\r\n $markup .= '<button class=\"overlay-only\">';\r\n $markup .= t('Explore more of this workshop');\r\n $markup .= '<\/button>';\r\n $vars['message']['#allowed_tags'] = ['br', 'button'];\r\n }\r\n else {\r\n $markup = t('Thank you for your feedback.');\r\n }\r\n\r\n $vars['message']['#markup'] = $markup;\r\n }\r\n}<\/pre>\nUntil I set the #allowed_tags element I was unable to get the button tag to render (Drupal was stripping it out and just showing the text).<\/p>\n
Finally, I cleared the caches and tested the solution. Success!<\/p>\n
<\/p>\n","protected":false},"excerpt":{"rendered":"
There are a few reasons you may need to override a webform confirmation: Out of the box webform doesn’t allow you to add some tags (e.g., <button>) to a webform confirmation message. When you save it strips them out. What if you needed to alter the webform message based on the values submitted in the webform? What if you needed to alter the webform message based on where the user saw the webform? etc… Thankfully, you can use a standard preprocess hook to override the confirmation output. In this particular example I needed to override the output of the message to include a button tag. I needed this to only happen if specific GET params had specific values. First, I modified the confirmation message settings as shown here:<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[79],"tags":[84,300,58],"_links":{"self":[{"href":"https:\/\/agileadam.com\/wp-json\/wp\/v2\/posts\/2615"}],"collection":[{"href":"https:\/\/agileadam.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/agileadam.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/agileadam.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/agileadam.com\/wp-json\/wp\/v2\/comments?post=2615"}],"version-history":[{"count":5,"href":"https:\/\/agileadam.com\/wp-json\/wp\/v2\/posts\/2615\/revisions"}],"predecessor-version":[{"id":2622,"href":"https:\/\/agileadam.com\/wp-json\/wp\/v2\/posts\/2615\/revisions\/2622"}],"wp:attachment":[{"href":"https:\/\/agileadam.com\/wp-json\/wp\/v2\/media?parent=2615"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/agileadam.com\/wp-json\/wp\/v2\/categories?post=2615"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/agileadam.com\/wp-json\/wp\/v2\/tags?post=2615"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}