将名称从 "profile" 更改为 WordPress 用户名

Changing name from "profile" to the WordPress username

您好,我正在使用 WordPress 主题,当注册用户登录时,它会为每个用户显示 "profile" 的基本单词。我想将其更改为注册人的用户名。 我不太了解 WordPress 编码,如果有人解决这个问题就太好了。

这里有一张图片可以更清楚地说明:

这里是它调用的代码,我认为这段代码需要修改。

function user_link_menu(){
    $result= '';

    if( options::logic( 'general' ,  'user_login' ) ){ ?> 
        <div class="login-form b w_105"><!--Login form starts here-->
            <?php
                if( is_user_logged_in () ){
                    $u_id = get_current_user_id();

                    $picture = facebook::picture();
                    if( strlen( $picture ) && get_user_meta( $u_id , 'custom_avatar' , true ) == ''){
                        ?><a href="http://facebook.com/profile.php?id=<?php echo facebook::id(); ?>" class="profile-pic"><img src="<?php echo $picture; ?>" width="32" width="32" /></a><?php
                    }else{
                        echo '<a href="' . get_author_posts_url( $u_id ) . '" class="profile-pic">'  . cosmo_avatar( $u_id , 32 , $default = DEFAULT_AVATAR_LOGIN ) . '</a>';
                    }


                    $url = home_url();

                    $like = array( 'fp_type' => "like" );
                    $url_like = add_query_arg( $like , $url );

                    ?>
                        <div class="cosmo-icons"><!--Login logout links-->
                            <ul class="sf-menu">
                                <li class="signin">

                                    <a href="<?php echo get_author_posts_url( $u_id );  ?>"><?php _e('profile','cosmotheme'); ?></a>

                                    <ul>
                                        <?php if(is_numeric(options::get_value( 'general' , 'user_profile_page' )) && options::get_value( 'general' , 'user_profile_page' ) > 0){ ?>
                                                <li class="my-settings"><a href="<?php  echo get_page_link(options::get_value( 'general' , 'user_profile_page' ));  ?>"><?php _e( 'My settings' , 'cosmotheme' ); ?></a></li>
                                        <?php } ?>

                                        <li class="my-profile"><a href="<?php echo get_author_posts_url( $u_id ).'?type=post';  ?>"><?php _e( 'My profile' , 'cosmotheme' ); ?></a></li>

                                        <?php 
                                            if( options::logic( 'general' ,  'enb_likes' ) ){
                                                ?><li class="my-likes"><a href="<?php echo get_author_posts_url( $u_id ).'?type=like'; ?>"><?php _e( 'My loved posts' , 'cosmotheme' ); ?></a></li><?php
                                            }
                                        ?>
                                        <?php $post_item_page = get_page_by_title('Post Item');  ?>
                                        <li class="my-add"><a href="<?php  echo get_page_link($post_item_page->ID);;  ?>"><?php _e( 'Add post' , 'cosmotheme' ); ?></a></li>      

                                        <li class="my-logout"><a href="<?php echo wp_logout_url( home_url() ); ?>"><?php _e( 'Log out' , 'cosmotheme' ); ?></a></li>
                                    </ul>
                                </li>
                            </ul>
                        </div>
                    <?php
                }
            ?>
        </div>
        <?php } /*if enabled user login*/ 
}    

<?php _e('profile','cosmotheme'); ?> 更改为 <?=$username;?> 并在您的行前粘贴此代码:

<?php
global $current_user;
get_currentuserinfo();

if ( is_user_logged_in() ) { 
    $username = $current_user->user_login;
} else { 
    $username = 'Log in';
} ?>

编辑:

好的,添加这个:

global $current_user;
get_currentuserinfo();

在代码中的 if( is_user_logged_in () ){ 之前,将 <?php _e('profile','cosmotheme'); ?> 替换为 <?=$current_user->user_login;?>