【问题标题】:Wordpress frontend edit profile form - change avatarWordpress 前端编辑个人资料表单 - 更改头像
【发布时间】:2019-01-30 21:46:07
【问题描述】:

我有一个用于从前端编辑配置文件的表单。我里面有类似的东西:

do_action('edit_user_profile',$current_user);

如果我以管理员身份登录,此代码将输出:https://www.screencast.com/t/kIDEcbeD。如果订阅者已登录,则什么都没有 - 我只看到提交按钮。

【问题讨论】:

  • 没有更多代码分析,这只是一个方向的推动。 WP 不允许订阅者编辑用户。因此,如果您的代码依赖于登录用户自己编辑的能力,它将失败。

标签: forms edit profile avatar


【解决方案1】:

还有一段代码要分析:

                <form method="post" id="edituser" action="<?php the_permalink(); ?>">
                    <p class="form-username">
                        <label for="first_name"><?php _e('First name', 'example'); ?></label>
                        <input class="text-input" name="first_name" type="text" id="first_name" value="<?php the_author_meta( 'first_name', $current_user->ID ); ?>" />
                    </p><!-- .form-username -->
                    <p class="form-username">
                        <label for="last_name"><?php _e('Last name', 'example'); ?></label>
                        <input class="text-input" name="last_name" type="text" id="last_name" value="<?php the_author_meta( 'last_name', $current_user->ID ); ?>" />
                    </p><!-- .form-username -->
                    <p class="form-email">
                        <label for="user_email"><?php _e('E-mail', 'example'); ?></label>
                        <input class="text-input" name="user_email" type="text" id="user_email" value="<?php the_author_meta( 'user_email', $current_user->ID ); ?>" />
                    </p><!-- .form-email -->
                    <p class="form-url">
                        <label for="url"><?php _e('Website', 'example'); ?></label>
                        <input class="text-input" name="url" type="text" id="url" value="<?php the_author_meta( 'user_url', $current_user->ID ); ?>" />
                    </p><!-- .form-url -->
                    <p class="form-phone">
                        <label for="tc_phone"><?php _e('Phone', 'example'); ?></label>
                        <input class="text-input" name="tc_phone" type="text" id="tc_phone" value="<?php echo $phone_meta_value; ?>" />
                    </p><!-- .form-phone -->
                    <p class="form-password">
                        <label for="pass1"><?php _e('Password', 'example'); ?> </label>
                        <input class="text-input" name="pass1" type="password" id="pass1" />
                    </p><!-- .form-password -->
                    <p class="form-password">
                        <label for="pass2"><?php _e('Repeat password', 'example'); ?></label>
                        <input class="text-input" name="pass2" type="password" id="pass2" />
                    </p><!-- .form-password -->
                    <p class="form-textarea">
                        <label for="description"><?php _e('About me', 'example') ?></label>
                        <textarea name="description" id="description" rows="3" cols="50"><?php the_author_meta( 'description', $current_user->ID ); ?></textarea>
                    </p><!-- .form-textarea -->
                    <?php 
                        //action hook for plugin and extra fields
                        do_action('edit_user_profile',$current_user); 
                    ?>
                    <p class="form-submit">
                        <input name="updateuser" type="submit" id="updateuser" class="submit button" value="<?php _e('Update', 'example'); ?>" />
                        <?php wp_nonce_field( 'update-user' ) ?>
                        <input name="action" type="hidden" id="action" value="update-user" />
                    </p>
                </form>

【讨论】:

    猜你喜欢
    • 2012-03-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多