admin管理员组文章数量:1417723
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?
本文标签: user metaAdvanced Custom Fields frontend form submission
版权声明:本文标题:user meta - Advanced Custom Fields frontend form submission 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745274860a2651120.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论