Welcome "Joe Bloggs" message

24.10.2014 13:23
#1
BlooMort
Joomshopping forum user no avatar
Name: Stanley
19.04.2014
Posts: 17
Quote
Welcome "Joe Bloggs" message

How do I detect when, and which user is logged in so that I can display a welcome message and make button such as "log out", "my account" available in the header of my pages?

 
24.10.2014 13:56
#2
webdesigner
(Support Team)
User webdesigner
Name: Admin
05.08.2010
Posts: 16518
Quote
Aw: Welcome "Joe Bloggs" message

Install module login.

 
24.10.2014 14:18
#3
BlooMort
Joomshopping forum user no avatar
Name: Stanley
19.04.2014
Posts: 17
Quote
Aw: Welcome "Joe Bloggs" message

Thanks, but this is what I was looking for:

$user = JFactory::getUser();
if (!$user->guest) {
//do something
} else {
//do something else
}


 
24.10.2014 14:37
#4
BlooMort
Joomshopping forum user no avatar
Name: Stanley
19.04.2014
Posts: 17
Quote
Aw: Welcome "Joe Bloggs" message

This is the code I have inserted into index.php
<?php $user = JFactory::getUser();
$greet="";
if (!$user->guest) {
$greet="Welcome $user->name"; ?>
<div id="myaccount"> <?php echo $greet." "; ?>
<a href="index.php/component/jshopping/user">My Account</a> <a href="index.php/component/jshopping/cart">My Cart</a>
</div>
<?php } else { ?>
<div id="myaccount">
<a href="index.php/component/jshopping/user/login">Log in</a>
</div>
<?php } ?>


 
Copyrights MAXXmarketing GmbH. All Rights Reserved