Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Form submitted even if opt-in checkbox is unchecked #79

Open
eSaner opened this issue Dec 3, 2016 · 3 comments
Open

Form submitted even if opt-in checkbox is unchecked #79

eSaner opened this issue Dec 3, 2016 · 3 comments

Comments

@eSaner
Copy link

eSaner commented Dec 3, 2016

Forms are submitted even if the opt-in checkbox is unchecked. Adding an * doesn't help.

Same issue is reported by soneone else here: https://wordpress.org/support/topic/opt-in-field-with-checkbox-is-not-working/

@Typel
Copy link

Typel commented Feb 14, 2017

Experiencing the same behavior here. Is this still maintained? Signing people up when they haven't opted in is a major enough bug that it renders the plugin useless (or at least unethical).

For those of us who must still make this work regardless, I managed to find a workaround:

  1. In the database, open the wp_options table and search for option_name %cf7_ctct_% ( SELECT * FROM wp_options WHERE option_name LIKE '%cf7_ctct_%' )
  2. You should find a list - one for each CF7 form that has been integrated with the plugin.
  3. Open up the option_value field and copy the text into a comfortable editor - it's in condensed format so you'll have to be a little cautious making changes to it.
  4. Locate this part: s:6:"accept";s:0:""; and change it to this: s:6:"accept";s:13:"ctctcf7_lists"; - notice that s:0 changed to s:13 to reflect the number of characters in the word 'ctctcf7_lists' (the name of the opt-in checkbox field)
  5. Save the database edit
  6. Refresh the form in your browser and try it checked/unchecked - should work as expected now.

The big downside is that if you happen to modify and re-save the form, this edit disappears.

The bug seems to be that when a checkbox field is not specified (when a shortcode is used rather than a native Contact Form 7 field) this option does not get properly updated from the plugin. It only gets updated if an "Opt-In Field" gets selected on the Constant Contact tab. Then later in the code (cf7-constantcontact.php lines 770-780) it uses this flawed "accept" option in logic: if empty, it assumes there is no opt-in field and sends the contact to Constant Contact.

Typel added a commit to Typel/Contact-Form-7-Newsletter that referenced this issue Feb 15, 2017
Maybe not the most ideal way to fix this, but it does prevent the
'single' checkbox type from subscribing people who didn't opt in. Does
not affect the other types, although the dropdown select never did work
due to a different bug. A better way to fix this might be to add
'ctctcf7_lists' to the 'Opt-In Field' dropdown list on the Constant
Contact tab, but I haven't yet found where to add that - maybe something
the plugin author can address more adequately.
@Typel
Copy link

Typel commented Feb 15, 2017

Not sure if the above fix will be accepted - it isn't "production" quality, but if anybody absolutely needs this to work in a pinch, adding those 3 lines of code should do the trick while we wait for an official update. It modifies how the plugin saves its 'accept' config variable so that if the 'single checkbox' Opt-In method is used, it still knows which field to check.

@jgream
Copy link

jgream commented Jul 6, 2017

Another suggested workaround... It doesn't seem to have a problem when you give the user multiple lists to choose from. So, you can trick it by setting it up as if the user is subscribing to multiple lists, but you only give them a single option. The original form input would look something like this:

Original code for single list opt-in:

[ctct ctct-367 label:Please+keep+me+informed+about+new+products+and+services. type:single 'Marketing Updates & News::#2019058xxx']

Modified, making the checkbox checked by default, changing type to "checkboxes", and replacing the name of the list with the text you want to display. The actual name of the list doesn't seem to matter, but the ID does.

[ctct ctct-367 acceptance accept-this-3 invert default:on type:checkboxes 'Please keep me informed about new products and services.::#2019058xxx']

This does generate an <li> for your item, so you may want to hide the bullet point via CSS. I'm sure there are ways to handle it programatically, but this method worked for me without having to modify the database or plugin code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants