侧边栏登录:如何在“欢迎”后显示用户名?

时间:2011-06-29 作者:Julia

哟,在我将\\uU()应用于“Welcome”字符串之前,侧栏登录通常会说“Welcome%username%”,没有问题。从那时起,欢迎信息只会说“欢迎”(所有语言),但我不能把用户名带回来救我的命。我做错了什么?下面是它的外观:

函数widget\\u wp\\u sidebarlogin($args){global$user\\u ID,$current\\u user;

    /* To add more extend i.e when terms came from themes - suggested by dev.xiligroup.com */
    $defaults = array(
        \'thelogin\'=>__(\'Login\'),
        \'thewelcome\'=>__(\'Welcome\'),
        \'theusername\'=>__(\'Username:\',\'sblogin\'),
        \'thepassword\'=>__(\'Password:\',\'sblogin\'),
        \'theremember\'=>__(\'Remember me\',\'sblogin\'),
        \'theregister\'=>__(\'Register\',\'sblogin\'),
        \'thepasslostandfound\'=>__(\'Password Lost and Found\',\'sblogin\'),
        \'thelostpass\'=> __(\'Lost your password?\',\'sblogin\'),
        \'thelogout\'=> __(\'Logout\',\'sblogin\')
    );

    $args = array_merge($defaults, $args);
    extract($args);     

    get_currentuserinfo();

    if ($user_ID != \'\') {
        // User is logged in

        global $current_user;
        get_currentuserinfo();

        if (empty($thewelcome)) $thewelcome = str_replace(\'%username%\',ucwords($current_user->display_name),get_option(\'sidebarlogin_welcome_heading\'));

        echo $before_widget . $before_title . __("Welcome") . $user_info->user_login . $after_title;

        if (get_option(\'sidebar_login_avatar\')==\'yes\') echo \'<div class="avatar_container">\'.get_avatar($user_ID, $size = \'38\').\'</div>\';

        echo \'<ul class="pagenav">\';

        if(isset($current_user->user_level) && $current_user->user_level) $level = $current_user->user_level;

        $links = do_shortcode(trim(get_option(\'sidebarlogin_logged_in_links\')));

        $links = explode("\\n", $links);
        if (sizeof($links)>0)
        foreach ($links as $l) {
            $l = trim($l);
            if (!empty($l)) {
                $link = explode(\'|\',$l);
                if (isset($link[1])) {
                    $cap = strtolower(trim($link[1]));
                    if ($cap==\'true\') {
                        if (!current_user_can( \'manage_options\' )) continue;
                    } else {
                        if (!current_user_can( $cap )) continue;
                    }
                }
                // Parse %USERNAME%
                $link[0] = str_replace(\'%USERNAME%\',$current_user->user_login,$link[0]);
                $link[0] = str_replace(\'%username%\',$current_user->user_login,$link[0]);
                // Parse %USERID%
                $link[0] = str_replace(\'%USERID%\',$current_user->ID,$link[0]);
                $link[0] = str_replace(\'%userid%\',$current_user->ID,$link[0]);
                echo \'<li class="page_item">\'.$link[0].\'</li>\';
            }

    }
格雷西亚斯。。。

2 个回复
SO网友:Bainternet

改变

$user_info->user_login

$current_user->login

SO网友:Ramkumar M

我不知道你的密码。但我还有一个建议。只需尝试安装插件并欢迎您的网站用户。Ajax Login/Register . 这个插件工作正常。我想你会有帮助的。

结束

相关推荐

流视频播放器不能使用DO_SHORTCODE()?

我下载了一个名为Stream Video Player, 它有一个短代码。如果我把这个短代码放在内容编辑器中,它会很好地工作,并显示视频。但是,如果在我创建的模板中,我通过do_shortcode() 函数,它不起作用,它只显示文本[stream bla bla]. 谁能帮帮我,告诉我为什么会这样?