| @@ -81,12 +81,25 @@ | ||
| 81 | 81 | 'code' => $error->getCode(), |
| 82 | 82 | 'message' => $error->getMessage(), |
| 83 | 83 | 'form_id' => $formId, |
| 84 | 84 | 'time' => time(), |
| 85 | - 'hide_confirmation' => (bool) apply_filters( 'f12_cf7_doubleoptin_show_validation_error', false ), | |
| 85 | + 'hide_confirmation' => $error->shouldShowToVisitor( $formId ), | |
| 86 | 86 | ), |
| 87 | 87 | self::TRANSIENT_TTL |
| 88 | 88 | ); |
| 89 | + } | |
| 90 | + | |
| 91 | + /** | |
| 92 | + * Drop the stored error for the current client. | |
| 93 | + * | |
| 94 | + * For integrations that already put the message into the form's own | |
| 95 | + * response (CF7 abort, Elementor error). Without this the toast shows | |
| 96 | + * the same sentence a second time next to it. | |
| 97 | + * | |
| 98 | + * @return void | |
| 99 | + */ | |
| 100 | + public static function forget(): void { | |
| 101 | + delete_transient( self::getTransientKey() ); | |
| 89 | 102 | } |
| 90 | 103 | |
| 91 | 104 | /** |
| 92 | 105 | * Retrieve and delete the stored error for the current client. |