Support

Account

Home Forums Front-end Issues Saving front-end checkbox with ajax

Helping

Saving front-end checkbox with ajax

  • I have a popup window with a checkbox, which I want to use to save a user’s preference. It is currently not in a form, but it can be if I need to. I’ve used ACF in the back-end quite a bit, but not in the front. How if at all would i use ACF to make this checkbox save to database on user click, but without any POST? As mentioned there’s no form and I could wrap the checkbox with one, but would like it to still not require any submit.

    Context:
    The checkbox currently, when checked, unhides a button allowing the user to close that window. This same checkbox, hopefully, can save a 1 or a 0 to the database with Ajax, in order to not show that window to the user again.

    Is there a way to do this using ACF. presumably front-end forms?

    Thanks!
    Ben

  • You would need to write JavaScript that fires when it is checked and then make an AJAX request that does the saving. I would not use an acf_form() for this, but I might use an ACF field on for the user. https://codex.wordpress.org/AJAX_in_Plugins

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.