user meta - Advanced Custom Fields frontend form submission

I have made a front-end form that allows the users to setupdate a few user meta fields made with Advanced Custom Fields

I have made a front-end form that allows the users to set\update a few user meta fields made with Advanced Custom Fields (there are user preferences, mostly: dark\light mode, etc.).

The preferences are set through an HTML form:

        <form id="cl_style_form" class="cl_style_form" action="" method="post">
            <input id="cl_dark_input" name="cl_dark_input" type="hidden" value="<?php echo $cl_dark; ?>"/>
            <input id="cl_compact_input" name="cl_compact_input" type="hidden" value="<?php echo $cl_compact; ?>"/>
            <input id="cl_style_form_submit" name="cl_style_form_submit" type="submit"/>
        </form>

and sent using the PHP Post method:

        if(isset($_POST['cl_style_form_submit'])){
            update_field('cl_dark', $_POST['cl_dark_input'], 'user_'.$cl_user);
            update_field('cl_compact', $_POST['cl_compact_input'], 'user_'.$cl_user);
        }

I am, however, encountering an issue. Whenever the submit button is pressed and the page is reloaded, the changes are not applied. Reloading the page a second time (without re-submitting the form data) applied the changes correctly.

I am not sure why this is happening.

Maybe the reload happens when the fields are still being updated?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745274861a4619975.html

相关推荐

  • user meta - Advanced Custom Fields frontend form submission

    I have made a front-end form that allows the users to setupdate a few user meta fields made with Advanced Custom Fields

    8小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信