当前位置:LaySNS首页 > 技术交流

【DiscuzX2.5】显示真实姓名(持续更新)

楼主:云阳 时间:2018-05-16 16:37:04 点击:2029 回复:0

1、\source\function\function_core.php 增加一个方法

//根据username显示真实姓名
function getrealname($username)
{
    $uid = C::t('common_member')->fetch_uid_by_username($username);
	static $nickname_users = array();
	if (empty($nickname_users[$uid])) {
        $nickname_users[$uid] = C::t('common_member_profile' . ($fetch_archive === 2 ? '_archive' : ''))->fetch($uid);
        if ($fetch_archive === 1 && empty($nickname_users[$uid])) {
            $nickname_users[$uid] = C::t('common_member_archive')->fetch($uid);
        }
    }
    if (!isset($nickname_users[$uid]['self']) && $uid == getglobal('uid') && getglobal('uid')) {
        $nickname_users[$uid]['self'] = 1;
    }
    return $nickname_users[$uid];
}

2、\source\function\function_forumlist.php第152行位置(版主)

function moddisplay($moderators, $type, $inherit = 0) {
	if($moderators) {
		$modlist = $comma = '';
		foreach(explode("\t", $moderators) as $moderator) {
			$moderatorrealname=getrealname($moderator)['realname'];
			$modlist .= $comma.'<a href="home.php?mod=space&username='.rawurlencode($moderator).'" class="notabs" c="1">'.($inherit ? ''.$moderatorrealname.'' : $moderatorrealname).'';
			$comma = ', ';
		}
	} else {
		$modlist = '';
	}
	return $modlist;
}


0.108243s