问题描述
我是 wordpress 和 PHP 的新手,我正在尝试构建一个表单,用户可以在其中从前端更新其兴趣(该表单将显示在自定义 WooCommerce 端点中)。 到目前为止我所管理的:
但是,我无法通过表单来保存修改...我想我在构建表单的方式中遗漏了一些东西(可能涉及 JS 或 Ajax?)。
到目前为止,这是我的 PHP 代码(来自我的自定义端点:my-account-mesinterets.PHP):
<form method="post" id="adduser" action="<?PHP the_permalink(); ?>">
<fieldset>
<?PHP
$auth_id = $post->post_author;
$data = get_user_Meta($auth_id,'MyInterests',true); ?>
<label for="wood-sculpture">Travail du bois (sculpture,marqueterie)</label>
<input name="MyInterests[]" type="checkBox" id="wood-sculpture" value="wood-sculpture" <?PHP
if(!empty($data) && !is_wp_error($data))
if (in_array('wood-sculpture',$data)) {
echo 'checked';
} ?> >
<br>
<label for="wood-creation">Travail du bois (création de meubles et d'objets)</label>
<input name="MyInterests[]" type="checkBox" id="wood-creation" value="wood-creation" <?PHP
if(!empty($data) && !is_wp_error($data))
if (in_array('wood-creation',$data)) {
echo 'checked';
} ?> >
<br>
<label for="jewelry">Bijouterie (avec métaux précieux,bois,pierres,autres...)</label>
<input name="MyInterests[]" type="checkBox" id="jewelry" value="jewelry" <?PHP
if(!empty($data) && !is_wp_error($data))
if (in_array('jewelry',$data)) {
echo 'checked';
} ?> >
<br>
<label for="deco">Déco</label>
<input name="MyInterests[]" type="checkBox" id="deco" value="deco" <?PHP
if(!empty($data) && !is_wp_error($data))
if (in_array('deco',$data)) {
echo 'checked';
} ?> >
<br>
<label for="pottery">Poterie</label>
<input name="MyInterests[]" type="checkBox" id="pottery" value="pottery" <?PHP
if(!empty($data) && !is_wp_error($data))
if (in_array('pottery',$data)) {
echo 'checked';
} ?> >
<br>
<label for="Metal">Travail du métal</label>
<input name="MyInterests[]" type="checkBox" id="Metal" value="Metal" <?PHP
if(!empty($data) && !is_wp_error($data))
if (in_array('Metal',$data)) {
echo 'checked';
} ?> >
<br>
<label for="music-instruments">Création d'instruments de musique</label>
<input name="MyInterests[]" type="checkBox" id="music-instruments" value="music-instruments" <?PHP
if(!empty($data) && !is_wp_error($data))
if (in_array('music-instruments',$data)) {
echo 'checked';
} ?> >
<br>
<label for="leather">Travail du cuir</label>
<input name="MyInterests[]" type="checkBox" id="leather" value="leather" <?PHP
if(!empty($data) && !is_wp_error($data))
if (in_array('leather',$data)) {
echo 'checked';
} ?> >
<br>
<label for="floral-art">Art floral</label>
<input name="MyInterests[]" type="checkBox" id="floral-art" value="floral-art" <?PHP
if(!empty($data) && !is_wp_error($data))
if (in_array('floral-art',$data)) {
echo 'checked';
} ?> >
<br>
<label for="other">Autres</label>
<input name="MyInterests[]" type="checkBox" id="other" value="other" <?PHP
if(!empty($data) && !is_wp_error($data))
if (in_array('other',$data)) {
echo 'checked';
} ?> >
<br>
</fieldset>
<p class="form-submit">
<input name="updateuser" type="submit" id="updateuser" class="submit button" value="<?PHP _e('Update','profile'); ?>" />
<?PHP wp_nonce_field( 'update-user' ) ?>
<input name="action" type="hidden" id="action" value="update-user" />
</p>
</form>
任何帮助将不胜感激。我真的被困在这里了。非常感谢!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)