• Resolved sarosh90

    (@sarosh90)


    I’m having an issue saving multiple checkbox values to desired meta key. If only 1 checkbox is checked the value is stored fine…but if i select multiple checkboxes nothing gets saved.

    Any help would be appreciated

Viewing 8 replies - 1 through 8 (of 8 total)
  • Hi @sarosh90,

    Selecting multiple value on checkbox should work fine. Can you please share more details about the form?? or if you have a live link please share.

    Thanks

    Thread Starter sarosh90

    (@sarosh90)

    So i have created a post form that has a checkbox field

    example:

    label:cars
    option 1:bmw
    option 2:fiat
    option 3:vw

    I’ve then set the checkbox meta key to corespond with my identical checkbox list in my backend (I used meta-box to create a custom checkbox list for my posts).

    If only 1 checkbox is checked the value gets saved fine

    example:
    I check BMW checkbox (on the post form)…the value gets checked in my backend checkbox list as well.

    If i check multiple checkboxes nothing gets saved in my backend.

    I’ve also found an identical post regarding this problem (no fix there)

    https://wedevs.com/support/topic/checkboxmultiselect-values-stores-as-string-value/

    Hello @sarosh90,

    I understand your problem. As we save multiple values as a string therefore in your backend checkbox form can’t read it as it expects an array.

    Let me check and see how can I give you an workaround for this.

    I will get back to you soon.

    Thanks

    So, I have created a hot fix for you now. We will release an update in future which will allow you to select the way you want to save data in to Database either String Or Array for fields with multiple options.
    Till then please modify these part within your WPUF plugin :
    On File : wp-content/plugins/wp-user-frontend/class/render-form.php
    Line no : 284 Add this :

     case 'checkbox' :
                        $meta_key_value[$value['name']] = $_POST[$value['name']];
                        break;
    

    This should resolve your issue.

    Thanks

    Thread Starter sarosh90

    (@sarosh90)

    I added the provided snippet but nothing gets saved now…not even a single checkbox

    Did i miss something ? Do i need to add/change something else ?

    Try replacing the whole file with this file.

    Let me know if it works.

    Thanks

    Thread Starter sarosh90

    (@sarosh90)

    Same problem as before…nothing gets saved

    Seems like we need to check your site then as it’s working fine here after making the changes.

    I have already opened a issue in our github. You can keep track of this to know the progress of the fix in our future release.

    But for now you can contact our support and we will be happy to make these changes for you to make this work.

    Thanks
    With best Regards
    Rafsun

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Multiple checkboxes – meta key issue’ is closed to new replies.