{"id":13329500,"date":"2020-08-28T16:50:53","date_gmt":"2020-08-28T16:50:53","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/html-message-responses\/"},"modified":"2020-08-28T16:55:13","modified_gmt":"2020-08-28T16:55:13","slug":"html-message-responses","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/html-message-responses\/","title":{"rendered":"HTML Message responses"},"content":{"rendered":"<p>Hi,<br \/>\nI&#8217;m using your plugin with a gpdr cookie plugin with cf7 and active recapcha3.<br \/>\nWhen a user denies using third-party cookies (googles reCaptcha) and uses the contact form the server response is:<\/p>\n<pre><code>{\ninto: &quot;#wpcf7-f608-p826-o2&quot;\nmessage: &quot;&lt;div class=&quot;cmplz-blocked-content-notice cmplz-accept-cookies&quot;&gt;&lt;a href=&quot;#&quot;&gt;Click here to accept marketing cookie and enable this form&lt;\/a&gt;&lt;\/div&gt;&quot;\nposted_data_hash: &quot;&quot;\nstatus: &quot;spam&quot;\n}<\/code><\/pre>\n<p>There are two issues: SWAL shows success with the messagetext in html.<\/p>\n<p>I fixed this with this code (changed to html output) in file addon-sweetalert-contact-form-7.php:<\/p>\n<pre><code>var validMessage = function() {\n   Swal.fire({\n   icon: &quot;success&quot;,\n   title: &quot;&lt;?php echo esc_attr(strtoupper($title_success)); ?&gt;&quot;,\n   html: message,\n   timer: &lt;?php if (empty($duration_success)) {\n      echo &#039;3000&#039;;\n   } else {\n      echo esc_attr($duration_success);\n   } ?&gt;,\n   showConfirmButton: false\n   });\n};\nvar errorMessage = function() {\n   Swal.fire({\n      icon: &quot;warning&quot;,\n      title: &quot;&lt;?php echo esc_attr(strtoupper($title_error)); ?&gt;&quot;,\n      html: message,\n      timer: &lt;?php if (empty($duration_error)) {\n      echo &#039;3000&#039;;\n   } else {\n      echo esc_attr($duration_error);\n   } ?&gt;,\n   showConfirmButton: false\n   });\n};<\/code><\/pre>\n<p>Then I changed code around line 95:<br \/>\n<code>$(document).ajaxComplete(function(event, xhr) {<\/code> to get the xhr response and use it additional around line 124:<\/p>\n<pre><code>setSwal = $(&quot;form.wpcf7-form&quot;).hasClass(&quot;invalid&quot;) ? &quot;alert&quot; : &quot;success&quot;;\nif (typeof xhr.responseJSON !== &quot;undefined&quot; &amp;&amp; typeof xhr.responseJSON.status !== &quot;undefined&quot;) {\n   switch (xhr.responseJSON.status) {\n      case &quot;validation_failed&quot;:\n      case &quot;spam&quot;:\n         setSwal = &quot;alert&quot;\n      break;\n      case &quot;success&quot;:\n      setSwal = &quot;success&quot;\n      break;\n   }\n}<\/code><\/pre>\n<p>Don&#8217;t know if this is a suitable solution, but it works. Maybe you want to use it in the plugin<\/p>\n","protected":false},"template":"","class_list":["post-13329500","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/13329500","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":2,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/13329500\/revisions"}],"predecessor-version":[{"id":13329522,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/13329500\/revisions\/13329522"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=13329500"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}