简体   繁体   English

尝试获取用户名以在joomla 2.5中创建动态页面

[英]trying to get the username to create dynamic pages in joomla 2.5

After the user logs into my site, I want to store the username in a session variable, so that I can use that information in another dynamic page depending on which user that is logged in, 用户登录到我的网站后,我要将用户名存储在会话变量中,以便可以根据登录的用户在另一个动态页面中使用该信息,

How do I accomplish this. 我该如何做到这一点。

If your users are logging into Joomla and you need the username in a Joomla file such as a template file you can do the following: 如果您的用户正在登录Joomla,并且您需要Joomla文件(例如模板文件)中的用户名,则可以执行以下操作:

$user = $JFactory::getUser();
if (!$user->guest) {
    $username = $user->username;
}

if (!empty($username)) {
    echo $username;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM