I am building a custom webinar for humhub. I am using the Custom_pages modules (https://www.humhub.org/marketplace/details?id=13) How can i get the user details of the current logged in user inside my app?
Someone gave me this code to try
//plug in to Yii application
require_once('../protected/vendors/yii/yii.php');
Yii::createWebApplication('../protected/config/main.php');
//------------------
//print_r(Yii::app());
echo "<br />";
//check if user is logged in (not a guest)
if(!Yii::app()->user->isGuest)
{
//if logged in, display the username and ID
echo "<strong>Logged In.</strong>";
echo "<br />";
echo "Username: ".Yii::app()->user->name;
echo "<br />";
echo "User ID: ".Yii::app()->user->id;
}
else
{
//if not logged in, display username (Guest)
echo "<strong>Not Logged In.</strong>";
echo "<br />";
echo "Username: ".Yii::app()->user->name;
}
But for some reason line 3
makes the page not load. if i comment it out, the page loads but Yii
is empty.
Is there any way i can get the user details of the logged in user in this my third party app?
Any approach would be appreciated
Much more easy :
Other usefull vars :
I used your code and it worked fine for me however I needed to modify it for my needs. Maybe my modifications will work for you.
I put this at the top of a iframe custom page in humhub. When you need the username just use $hum_username.
Using sql select you can get anything you want out of the user table in the database WHERE id='$hum_uid'