aradianoff / recaptchacontact

reCaptcha Contact Plugin for Grav CMS (getgrav.org)
MIT License
8 stars 11 forks source link

Thank you message never disappears... #40

Open gripmedia opened 7 years ago

gripmedia commented 7 years ago

Hey there:

Thanks for your work on this plugin. I have noticed, once I submit a message, the thank you message appears. And then never disappears no matter how many times I reload the page.

Also, I have a one page modular site, and it was incredibly difficult to set up and confusing. You might want to add some documentation on modular pages as the "contact form" tab does not appear on modular pages, and I had to manually edit the .md file to get it to show up.

Thanks again...

bassplayer7 commented 7 years ago

First, thank you for the suggestion. I believe that there is a problem with modular pages now - as a result of a Grav update at some point I think.

If you have a chance, could you provide a little more detail regarding the thank you message? Perhap an example?

Also, if you want to submit a PR, that'd be great!

gripmedia commented 7 years ago

Pardon my ignorance,. what is a PR? Thanks!

-jerrt

On Jul 6, 2017, at 1:38 PM, Jesse Maxwell notifications@github.com wrote:

First, thank you for the suggestion. I believe that there is a problem with modular pages now - as a result of a Grav update at some point I think.

If you have a chance, could you provide a little more detail regarding the thank you message? Perhap an example?

Also, if you want to submit a PR, that'd be great!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/aradianoff/recaptchacontact/issues/40#issuecomment-313483067, or mute the thread https://github.com/notifications/unsubscribe-auth/ABpQ_8E3Y8UtutOKNcyQojjNIhJzaOS2ks5sLSnCgaJpZM4OKN2U.

bassplayer7 commented 7 years ago

It's short for Pull Request.

mn113 commented 6 years ago

I have the same issue as @gripmedia. I have a page with a contact form, and when the form is successfully submitted, the green success message appears above the form and won't disappear even when the page is reloaded.

On a hunch, I deleted Grav's 30-minute session cookie called grav-site-4a62a9c. The green message then disappeared on reload. However I suspect this is not a direct cause of the persistent recaptcha message.

I was wondering if the problem could be related to the fact that my contact form page has a sub-page (called 'thank-you') which I guess is supposed to be rendered after submission if Javascript is off?

PHP 5.6, Grav 1.3.2, Admin 1.5.2, Form 2.8.2, Recaptcha Contact 2.1.2 - hope you can shed some light or point me where to look.

gripmedia commented 6 years ago

I honestly gave up and just went to a honeypot method and that is working great.

On Aug 31, 2017, at 6:50 PM, mn113 notifications@github.com wrote:

I have the same issue as @gripmedia https://github.com/gripmedia. I have a page with a contact form, and when the form is successfully submitted, the green success message appears above the form and won't disappear even when the page is reloaded.

On a hunch, I deleted Grav's 30-minute session cookie called grav-site-4a62a9c. The green message then disappeared on reload. However I suspect this is not a direct cause of the persistent recaptcha message.

I was wondering if the problem could be related to the fact that my contact form page has a sub-page (called 'thank-you') which I guess is supposed to be rendered after submission if Javascript is off?

PHP 5.6, Grav 1.3.2, Admin 1.5.2, Form 2.8.2, Recaptcha Contact 2.1.2 - hope you can shed some light or point me where to look.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/aradianoff/recaptchacontact/issues/40#issuecomment-326466139, or mute the thread https://github.com/notifications/unsubscribe-auth/ABpQ_5b7tAZYusJnazW5bigoIiRbv5diks5sd2L7gaJpZM4OKN2U.

bassplayer7 commented 6 years ago

I would not be surprised if Grav has changed the way it handles sessions. The message should be cleared (internally) on every page request, but it sounds like that isn't working anymore.

Refer to this method: https://github.com/aradianoff/recaptchacontact/blob/master/recaptchacontact.php#L204

fbnvdblck commented 6 years ago

After updating Grav Core and all plugins I have installed, I have exactly the same issue.

If you need an emergency tempory fix before the plugin is revised, you can edit onTwigSiteVariables() method from recaptchacontact.php file like that:

public function onTwigSiteVariables() // Esto se procesa después de onPageInitialized
    {
        $config = $this->grav['config'];

        if ($config->get('plugins.recaptchacontact.enabled') || $this->shouldLoadCss) {
            if (!$config->get('plugins.recaptchacontact.disable_css')) {
                $this->grav['assets']->addCss('plugin://recaptchacontact/assets/recaptchacontact.css');
            } else {
                $this->grav['assets']->addCss('theme://assets/recaptchacontact.css');
            }

            $this->grav['twig']->twig_vars['recaptchacontact'] = $this->grav['config']->get('plugins.recaptchacontact');
            $this->grav['twig']->twig_vars['recaptchacontact']['message'] = $this->grav['session']->contact_message;
            $this->grav['twig']->twig_vars['recaptchacontact']['session'] = $this->grav['session']->form;
            $this->grav['session']->contact_message = null; // Temporary quick fix
        }
    }

If you don't want to save form field values in session either, you can call $this->clearSession() instead of $this->grav['session']->contact_message = null.