accepts_marketing checkbox not subscribing customers during registration

Hello, Community

Using the accepts_marketing checkbox, I’m attempting to enable customers to opt-in for email marketing when they register on a custom customer registration form that I’m integrating into my Shopify theme.

This is the code that I’m using right now:

<div class="form-field accepts-marketing"> <input type="hidden" name="customer[accepts_marketing]" value="false" /> <input type="checkbox" name="customer[accepts_marketing]"
    Value="true" id="RegisterForm-AcceptsMarketing"
    class="form-checkbox" > label for="RegisterForm-AcceptsMarketing" class="form-label">
    Sign up for email marketing
  </label> </div>

Although the checkbox functions properly and submits without any issues, the newly registered customers are not marked as marketing subscribers in the admin’s Customers section even when it is checked.

I have confirmed that:

The input name is customer[accepts_marketing]

The value is appropriately set to “true.”

The input is inside the {% form ‘create_customer’ %} block

Still, the customers are being created with accepts_marketing = false.

Has anyone faced this issue before? Is there something I’m missing or an update to how Shopify handles this field?

Thanks in advance!

You have the input twice in your example. Once with accept marketing false and once that a user can interact with.
This is likely what’s causing you the problem

Hey @Aswin_Jero_J_K, assuming you are following the example from the documentation then it should be working unless something has changed with the functionality like you have asked.

There may need to be a change to the store’s settings too, as I believe there is an option for double opt-in and if that is checked then I assume the customer would be set to false until they opt-in via an email link or something like that.

The double input is correct here, the checkbox will override the hidden one if checked so the server will receive or true or false (an unchecked checkbox isn’t sent to the server when you submit the form).

I’ve tested with the code from the documentation but the created customer isn’t subscribed to the email marketing