更改主题配置文件页面上的头像

时间:2014-09-09 作者:Chris

我正在使用主题“我的登录”插件,并试图允许订阅者将其个人资料更改为从计算机上载的个人资料。

我尝试了以下插件:

简单的本地化身,但单击上载或更新配置文件时,化身不会改变。

有什么方法可以做到这一点吗?

这是我的“主题我的登录”配置文件代码和“简单的本地化身”

<div class="login profile" id="theme-my-login<?php $template->the_instance(); ?>">
             <?php $template->the_action_template_message( \'profile\' ); ?>
             <?php $template->the_errors(); ?>
             <form id="your-profile" action="<?php $template->the_action_url( \'profile\' ); ?>" method="post" class="validate"<?php do_action( \'user_new_form_tag\' );?>>
                <?php wp_nonce_field( \'update-user_\' . $current_user->ID ); ?>
                <p>
                   <input type="hidden" name="from" value="profile" />
                   <input type="hidden" name="checkuser_id" value="<?php echo $current_user->ID; ?>" />
                </p>

                <?php if ( has_action( \'personal_options\' ) ) : ?>

                <h3><?php _e( \'Personal Options\' ); ?></h3>

                <table class="form-table">
                <?php do_action( \'personal_options\', $profileuser ); ?>
                </table>

                <?php endif; ?>

                <?php do_action( \'profile_personal_options\', $profileuser ); ?>

                <h3 class="nomargin"><?php _e( \'Name\' ); ?></h3>

                <table class="form-table">
                <tr>
                   <th><label for="user_login"><?php _e( \'Username\' ); ?></label></th>
                   <td><input type="text" name="user_login" id="user_login" value="<?php echo esc_attr( $profileuser->user_login ); ?>" disabled="disabled" class="regular-text" /> <span class="description"><?php _e( \'Your username cannot be changed.\', \'theme-my-login\' ); ?></span></td>
                </tr>

                <tr>
                   <th><label for="first_name"><?php _e( \'First Name\' ); ?></label></th>
                   <td><input type="text" name="first_name" id="first_name" value="<?php echo esc_attr( $profileuser->first_name ); ?>" class="regular-text" /></td>
                </tr>

                <tr>
                   <th><label for="last_name"><?php _e( \'Last Name\' ); ?></label></th>
                   <td><input type="text" name="last_name" id="last_name" value="<?php echo esc_attr( $profileuser->last_name ); ?>" class="regular-text" /></td>
                </tr>

                <tr>
                   <th><label for="nickname"><?php _e( \'Nickname\' ); ?> <span class="description"><?php _e( \'(required)\' ); ?></span></label></th>
                   <td><input type="text" name="nickname" id="nickname" value="<?php echo esc_attr( $profileuser->nickname ); ?>" class="regular-text" /></td>
                </tr>

                <tr>
                   <th><label for="display_name"><?php _e( \'Display name publicly as\' ); ?></label></th>
                   <td>
                      <select name="display_name" id="display_name">
                      <?php
                         $public_display = array();
                         $public_display[\'display_nickname\']  = $profileuser->nickname;
                         $public_display[\'display_username\']  = $profileuser->user_login;

                         if ( ! empty( $profileuser->first_name ) )
                            $public_display[\'display_firstname\'] = $profileuser->first_name;

                         if ( ! empty( $profileuser->last_name ) )
                            $public_display[\'display_lastname\'] = $profileuser->last_name;

                         if ( ! empty( $profileuser->first_name ) && ! empty( $profileuser->last_name ) ) {
                            $public_display[\'display_firstlast\'] = $profileuser->first_name . \' \' . $profileuser->last_name;
                            $public_display[\'display_lastfirst\'] = $profileuser->last_name . \' \' . $profileuser->first_name;
                         }

                         if ( ! in_array( $profileuser->display_name, $public_display ) )// Only add this if it isn\'t duplicated elsewhere
                            $public_display = array( \'display_displayname\' => $profileuser->display_name ) + $public_display;

                         $public_display = array_map( \'trim\', $public_display );
                         $public_display = array_unique( $public_display );

                         foreach ( $public_display as $id => $item ) {
                      ?>
                         <option <?php selected( $profileuser->display_name, $item ); ?>><?php echo $item; ?></option>
                      <?php
                         }
                      ?>
                      </select>
                   </td>
                </tr>
                </table>

                <h3 class="nomargin addmargintop20"><?php _e( \'Contact Info\' ); ?></h3>

                <table class="form-table">
                <tr>
                   <th><label for="email"><?php _e( \'E-mail\' ); ?> <span class="description"><?php _e( \'(required)\' ); ?></span></label></th>
                   <td><input type="text" name="email" id="email" value="<?php echo esc_attr( $profileuser->user_email ); ?>" class="regular-text" /></td>
                </tr>

                <tr>
                   <th><label for="url"><?php _e( \'Website\' ); ?></label></th>
                   <td><input type="text" name="url" id="url" value="<?php echo esc_attr( $profileuser->user_url ); ?>" class="regular-text code" /></td>
                </tr>

                <?php
                   foreach ( _wp_get_user_contactmethods() as $name => $desc ) {
                ?>
                <tr>
                   <th><label for="<?php echo $name; ?>"><?php echo apply_filters( \'user_\'.$name.\'_label\', $desc ); ?></label></th>
                   <td><input type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr( $profileuser->$name ); ?>" class="regular-text" /></td>
                </tr>
                <?php
                   }
                ?>
                </table>

                <h3 class="nomargin addmargintop20"><?php _e( \'About Yourself\' ); ?></h3>

                <table class="form-table">
                <tr>
                   <th><label for="description"><?php _e( \'Biographical Info\' ); ?></label></th>
                   <td><textarea name="description" id="description" rows="5" cols="30"><?php echo esc_html( $profileuser->description ); ?></textarea><br />
                   <span class="description"><?php _e( \'Share a little biographical information to fill out your profile. This may be shown publicly.\' ); ?></span></td>
                </tr>

                <?php
                $show_password_fields = apply_filters( \'show_password_fields\', true, $profileuser );
                if ( $show_password_fields ) :
                ?>
                <tr id="password">
                   <th><label for="pass1"><?php _e( \'New Password\' ); ?></label></th>
                   <td><input type="password" name="pass1" id="pass1" size="16" value="" autocomplete="off" /> <span class="description"><?php _e( \'If you would like to change the password type a new one. Otherwise leave this blank.\' ); ?></span><br />
                      <input type="password" name="pass2" id="pass2" size="16" value="" autocomplete="off" /> <span class="description"><?php _e( \'Type your new password again.\' ); ?></span><br />
                      <div id="pass-strength-result"><?php _e( \'Strength indicator\', \'theme-my-login\' ); ?></div>
                      <p class="description indicator-hint"><?php _e( \'Hint: The password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers and symbols like ! " ? $ % ^ &amp; ).\' ); ?></p>
                   </td>
                </tr>
                <?php endif; ?>
                </table>

               <?php
                 global $current_user;
                 get_currentuserinfo();
                 $myAv = new simple_local_avatars();
                 $myAv->edit_user_profile($current_user);
               ?>


                <p class="submit">
                   <input type="hidden" name="action" value="profile" />
                   <input type="hidden" name="instance" value="<?php $template->the_instance(); ?>" />
                   <input type="hidden" name="user_id" id="user_id" value="<?php echo esc_attr( $current_user->ID ); ?>" />
                   <input type="submit" class="button-primary kopa-button blue-button small-button" value="<?php esc_attr_e( \'Update Profile\' ); ?>" name="submit" />
                </p>


             </form>

          </div>

2 个回复
最合适的回答,由SO网友:Chris 整理而成

好的,我想我已经通过WP用户头像插件实现了。

我将此添加到我的登录配置文件表单的主题中。php,复制到我的主题文件夹的根目录。

<?php
   global $current_user;
   get_currentuserinfo();
   do_action(\'edit_user_avatar\', $current_user);
?>
然后我将其添加到我的函数中。php文件:

function my_avatar_filter() {
  // Remove from show_user_profile hook
  remove_action(\'show_user_profile\', array(\'wp_user_avatar\', \'wpua_action_show_user_profile\'));
  remove_action(\'show_user_profile\', array(\'wp_user_avatar\', \'wpua_media_upload_scripts\'));

  // Remove from edit_user_profile hook
  remove_action(\'edit_user_profile\', array(\'wp_user_avatar\', \'wpua_action_show_user_profile\'));
  remove_action(\'edit_user_profile\', array(\'wp_user_avatar\', \'wpua_media_upload_scripts\'));

  // Add to edit_user_avatar hook
  add_action(\'edit_user_avatar\', array(\'wp_user_avatar\', \'wpua_action_show_user_profile\'));
  add_action(\'edit_user_avatar\', array(\'wp_user_avatar\', \'wpua_media_upload_scripts\'));
}

// Loads only outside of administration panel
if(!is_admin()) {
  add_action(\'init\',\'my_avatar_filter\');}
一切似乎都按预期进行:)

SO网友:user114542

我还使用简单的本地头像和我的登录主题。我也有同样的问题。我的解决方案非常简单。检查配置文件表单中的表单。php模板目录。并将enctype属性添加到表单(enctype=“多部分/表单数据”)

结束

相关推荐

Secure login on wordpress

我想在wordpress上创建一个登录页面,用户在其中键入用户名和密码,并重定向到指定给用户的页面,例如,如果您登录facebook或出价或购买。我希望能够让用户登录到一个页面,在那里他们可以找到只对特定用户可用的文件。就像电子学习一样。