• Hi,
    I’m using your plugin with a gpdr cookie plugin with cf7 and active recapcha3.
    When a user denies using third-party cookies (googles reCaptcha) and uses the contact form the server response is:

    {
    into: "#wpcf7-f608-p826-o2"
    message: "<div class="cmplz-blocked-content-notice cmplz-accept-cookies"><a href="#">Click here to accept marketing cookie and enable this form</a></div>"
    posted_data_hash: ""
    status: "spam"
    }

    There are two issues: SWAL shows success with the messagetext in html.

    I fixed this with this code (changed to html output) in file addon-sweetalert-contact-form-7.php:

    var validMessage = function() {
       Swal.fire({
       icon: "success",
       title: "<?php echo esc_attr(strtoupper($title_success)); ?>",
       html: message,
       timer: <?php if (empty($duration_success)) {
          echo '3000';
       } else {
          echo esc_attr($duration_success);
       } ?>,
       showConfirmButton: false
       });
    };
    var errorMessage = function() {
       Swal.fire({
          icon: "warning",
          title: "<?php echo esc_attr(strtoupper($title_error)); ?>",
          html: message,
          timer: <?php if (empty($duration_error)) {
          echo '3000';
       } else {
          echo esc_attr($duration_error);
       } ?>,
       showConfirmButton: false
       });
    };

    Then I changed code around line 95:
    $(document).ajaxComplete(function(event, xhr) { to get the xhr response and use it additional around line 124:

    setSwal = $("form.wpcf7-form").hasClass("invalid") ? "alert" : "success";
    if (typeof xhr.responseJSON !== "undefined" && typeof xhr.responseJSON.status !== "undefined") {
       switch (xhr.responseJSON.status) {
          case "validation_failed":
          case "spam":
             setSwal = "alert"
          break;
          case "success":
          setSwal = "success"
          break;
       }
    }

    Don’t know if this is a suitable solution, but it works. Maybe you want to use it in the plugin

    • This topic was modified 4 years, 3 months ago by iuvabo.
    • This topic was modified 4 years, 3 months ago by iuvabo. Reason: Formatting
  • The topic ‘HTML Message responses’ is closed to new replies.