[Subscribe By E-mail] function not working.

I have a custom JS function that was sent by WPMU DEV support, it was working perfectly but it stopped working.
No big updated or function changes were made, it is the subscribe by e-mail plugin, it should have a checkbox for GDPR, but it is gone now.
Can you help me?

  • Adam Czajczyk
    • Support Gorilla

    Hello mpress

    I hope you're well today!

    I checked the staging (sbe...) site and I can see the code added via the "Custom CSS & JS Code". The code added there had some errors as if added via this plugin it doesn't require "<script>" "</script>" tags and the form ID was incorrect for this staging site.

    However, adjusting that didn't really help, unfortunately. I'm not sure about the code itself though, it doesn't look quite right to me and the post that's been linked in the chat doesn't include any related CSS code. Since it's working on your other site, could you please take this entire JS from that working site (I assume it's added the very same way) and share it with me here "as-is", without any modifications whatsoever?

    This would give me a "starting point" and I believe based on this we could make it work again (along with explanation for future in case of any changes).

    Best regards,
    Adam

    • mpress
      • Code Wrangler

      H Adam Czajczyk ,

      Yes, it is added the same way, actually staging is created using Softaculous (both for concept... and for sbe....)

      This is the code for the concept. site, where it is working.

      ===Edited ===== . Code deleted - it has site url :slight_smile:

      Access is granted for site concept... .

      Cheers.

  • Adam Czajczyk
    • Support Gorilla

    Hi mpress

    Thanks, that helped :slight_smile:

    I did some more checking and moved on a "small step forward", though I think we'll actually need to go through this "step by step" as this entire set of code (the original one) looks a bit like a set of separate pieces added there and, being perfectly honest, I'm not quite following it.

    So I did something different instead:

    - I've disabled the original code snippet (keeping it on site - I'm working on staging one only of course - intact but not active)
    - I created another one called "Subscribe by Email Control v 2) and started moving pieces of code there, adjusting it.

    At this moment, the placeholders are updated and the "privacy checkbox" (with link) is showing up there.

    Can you take a look and tell me what - elements or behaviors - are still missing there?

    I'll give it another go and I think we'll get it to work again :slight_smile:

    Best regards,
    Adam

  • Adam Czajczyk
    • Support Gorilla

    Hi mpress

    Checkbox needs to be mandatory.

    I knew I missed something important :slight_smile: It's mandatory now. It's made with a different code, a bit more universal and simple but the outcome is the same: by default the "privacy checkbox" is not checked and the button is disabled and the button gets enabled/disabled upon checking/un-checking the "privacy checkbox". So that's just like on "concept..." site.

    PS: this js was also used to get this checkbox to the "follow us" button from SBE

    That's actually something that confused me a bit. On a "concept" site I don't see any button like this, although I see the code. Where can I see that? It'll be easier for me to just test it first.

    Best regards,
    Adam

    • mpress
      • Code Wrangler

      Hi Adam Czajczyk ,

      by default the "privacy checkbox" is not checked and the button is disabled and the button gets enabled/disabled upon checking/un-checking the "privacy checkbox".

      Yeah, it needs to work this way, I will have a look at it again.

      Where can I see that? It'll be easier for me to just test it first

      I have another site with access granted rkp.... this is a multisite install. go to the subsite par... you will see bottom button "follow us (volg us)" there :slight_smile:

      Cheers!

  • Adam Czajczyk
    • Support Gorilla

    Hi mpress

    Thanks for information, I found it.

    I was confused at first because I didn't see it on "sbe..." staging site but apparently it was simply disabled in plugin settings. So, after enabling it back I've made yet another modification to the JS and it seems to be fine now: all forms have the placeholders updated and "privacy checkbox" added and in all of them the button is disabled until the privacy checkbox is checked.

    Best regards,
    Adam

  • Adam Czajczyk
    • Support Gorilla

    Hi mpress

    Is it possible to have a warning when visitor tries to use "aanmelden" button before checking privacy?

    No, not with that kind of code (both original one and mine) because the code disabled the button - as it was in original one - so it can't be clicked. There's no "click" even on disabled input so it cannot be captured and as a consequence nothing can be triggered with that.

    The alternate approach is to keep the button active so it could be clicked but instead prevent it from submitting the form if the checkbox is not checked - so if checkbox is not checked form button would still be "clickable" but wouldn't submit the form and would show a message. That's doable but it would mean a completely new and different code, created from scratch.

    Also, I have tried to find how to translate warning messages, but was not able to find it by the .po .

    You mean those validation messages such as e.g. "Please fill out this field" when you try to submit an empty form? If yes than you won't find that anywhere in the plugin code.

    The message is generated... by browser. It will always use language of user's browser, regardless of what language is used on site. It's a matter of a "required" attribute of a HTML "input" field. For example, I got one browser set to Polish and one to English - in each of them the message uses relevant language (Polish/English). Furthermore, it even looks different in different browsers (e.g. in chrome it's white with yellow border while in Firefox it's gray(ish) tooltip).

    Best regards,
    Adam

    • mpress
      • Code Wrangler

      Hi Adam Czajczyk ,

      You are really fast :slight_smile:
      I will be in contact with website owner to check with option will be chosen. (with or without this last/label option).

      I see your code has comments that helps non tech people (as myself) to understand a little bit more what is going on.

      Thanks very much.

      Cheers.

    • mpress
      • Code Wrangler

      Hi Adam Czajczyk ,

      me again :slight_smile:

      I just saw theme has an option to add js. So I thought let's use this 'cause then I can delete one plugin (Custom js).

      So I copied your code - completely - over there.
      after that I have deactivated custom js and also deactivated plugin.

      Now I see checkbox is gone.

      Could you please check it for me?

      Thanks.

  • Adam Czajczyk
    • Support Gorilla

    Hello mpress

    The checkbox is gone because in that code there's no... html for "<input>" field as it was in the code added through the plugin. I just tested it and apparently theme is... stripping that part of the code for some reasons.

    I'm not sure why but I guess theme's just filtering it for some security purposes. The field is described as a field for code for e.g. analytics or ads (and those usually do not contain tags such as "<input>") so I suppose that's why it's stripping it.

    Perhaps it would be possible to disable such filter but that'd be the question to theme (or theme's framework if it's based on some framework) developers, I'm afraid. In this case, I'd suggest getting back to the plugin that you were using previously then.

    Best regards,
    Adam

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.