通过提交表单将用户信息保存在同一页上 时间:2017-11-29 作者:Alexander Taranenko 我已经搜索并看到了几个与此类似的问题和答案,但它们都不适合我。请帮我回答正确的问题!谢谢你!<?php if (isset($_POST[\'info_submit\'])){ $user->data->user_nicename = $_POST[\'user_first_name\'].\'-\'.$_POST[\'user_last_name\']; $user->data->display_name = $_POST[\'user_first_name\'].\'-\'.$_POST[\'user_last_name\']; $user->data->user_email = esc_attr( $_POST[\'user_email\'] ); wp_update_user($user); update_user_meta($user_id , \'user_firstname\' , $_POST[\'user_first_name\']); update_user_meta($user_id , \'user_lastname\' , $_POST[\'user_last_name\']); } ?> <form class="" name="info_form" id="info_form" action="" enctype="text/plain" method="post"> <div class="form-group"> <div class="form-input"> <label for="user_email">Email</label> <input required type="email" name="user_email" id="user_email" value="<?php echo get_userdata($user_id)->user_email;?>" required/> </div> <div class="form-input"> <label for="user_first_name">First Name</label> <input required type="text" name="user_first_name" id="user_first_name" value="<?php echo get_userdata($user_id)->user_firstname;?>" required/> </div> <div class="form-input"> <label for="user_last_name">Last Name</label> <input required type="text" name="user_last_name" id="user_last_name" value="<?php echo get_userdata($user_id)->user_lastname;?>" required/> </div> <div class="form-input"> <label for="user_display_name">Display Name</label> <input required type="text" name="user_display_name" id="user_display_name" value="<?php echo get_userdata($user_id)->display_name;?>" required/> </div> <div class="form-input"> <input type="submit" value="Save" name="info_submit" id="info_submit" /> </div> </div> </form> 1 个回复 SO网友:Daniel Fonda 我很确定您应该在表单“action”属性下添加页面url(不要硬编码)。因此,假设您有权访问\\u permalink(),则应执行以下操作:action="<?php the_permalink(); ?>" 通过在该文件的某处添加以下内容,检查是否将其保存到$\\u POST数组中,然后尝试提交表单:<?php var_dump($_POST);?> 结束 文章导航