if($my->id) does not work in joomla 1.5.6

Everything to do with Joomla! 1.5 templates and templating.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Locked
mamunnu
Joomla! Apprentice
Joomla! Apprentice
Posts: 38
Joined: Thu Sep 18, 2008 7:02 am
Location: Dhaka,Bangladesh.
Contact:

if($my->id) does not work in joomla 1.5.6

Post by mamunnu » Thu Sep 18, 2008 7:13 am

Dear All,

I try to check if the user is logged in or not for this I use

if($my->id>0){
echo "Login";
}else
{
echo "Not login";
}

The same code work in joomla 1.5.3 it is ok in 1.5.3

but in 1.5.6 it does not work,

It only print Not Login in both case.

Thanks
Mamun
Best Regards,
RadiusTheme
https://www.radiustheme.com/joomla/joomla-templates/
Free & Premium Joomla Components & Templates.

GameDaddy
Joomla! Guru
Joomla! Guru
Posts: 725
Joined: Sun Aug 24, 2008 4:35 pm

Re: if($my->id) does not work in joomla 1.5.6

Post by GameDaddy » Thu Sep 18, 2008 1:32 pm

Why not...

Site > Control Panel

On the right column there are five items:

Welcome to Joomla!
Logged in Users
Popular
Recent Added Articles
Menu Stats

Click on Logged in Users

mamunnu
Joomla! Apprentice
Joomla! Apprentice
Posts: 38
Joined: Thu Sep 18, 2008 7:02 am
Location: Dhaka,Bangladesh.
Contact:

Re: if($my->id) does not work in joomla 1.5.6

Post by mamunnu » Fri Sep 19, 2008 6:27 am

Thanks for your reply.

But this is not the right solution.

I want this if user is login then give message "Welcome to User Name"

otherwise "Welcome to Guest"

For this I need to this
if($my->id>0){
echo "Login";
}else
{
echo "Not login";
}

This code does not work.

please help me.

Thanks
Mamun
Best Regards,
RadiusTheme
https://www.radiustheme.com/joomla/joomla-templates/
Free & Premium Joomla Components & Templates.

GameDaddy
Joomla! Guru
Joomla! Guru
Posts: 725
Joined: Sun Aug 24, 2008 4:35 pm

Re: if($my->id) does not work in joomla 1.5.6

Post by GameDaddy » Fri Sep 19, 2008 11:33 am

mamunnu wrote:Thanks for your reply.

But this is not the right solution.

I want this if user is login then give message "Welcome to User Name"

otherwise "Welcome to Guest"

For this I need to this
if($my->id>0){
echo "Login";
}else
{
echo "Not login";
}

This code does not work.

please help me.

Thanks
Mamun
Ah yes... You'll find more on this here...

http://docs.joomla.org/Accessing_the_cu ... ser_object

Try that...

User avatar
coolparth
Joomla! Explorer
Joomla! Explorer
Posts: 264
Joined: Mon Oct 10, 2005 12:26 pm
Location: Pune, India

Re: if($my->id) does not work in joomla 1.5.6

Post by coolparth » Tue Dec 02, 2008 4:55 pm

Code: Select all

$uid =& JFactory::getUser();
$uid= $uid->id;
Try this
Parth Lawate Director
Tekdi Web Solutions. http://www.tekdi.net
Techjoomla. http://www.techjoomla.com

da8iwr
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 190
Joined: Sat Jan 14, 2006 1:59 pm
Location: Sunderland UK
Contact:

Re: if($my->id) does not work in joomla 1.5.6

Post by da8iwr » Fri May 22, 2009 2:52 am

Hi Did, you ever find a solution for this, as i have just found a similar problem, i have upgraded one of my sites and now it doesnt work properly.

Code: Select all

			    <?php
				if ($my->id ) {
					echo "logged in";
				} else {
					echo "logged out";
				}
				?>
That should be showing the message logged out if your not logged in, and logged in if you are logged in, but it doesn, it just shows logged out constantly.

Any idea?
Thanks
Ian

PS i usually use this to put in module positions such as

Code: Select all

			    <?php
				if ($my->id ) {
					echo "<jdoc:include type=\"modules\" name=\"user1\" headerLevel=\"3\" />";
				} else {
					echo "<jdoc:include type=\"modules\" name=\"user2\" headerLevel=\"3\" />";
				}
				?>

User avatar
coolparth
Joomla! Explorer
Joomla! Explorer
Posts: 264
Joined: Mon Oct 10, 2005 12:26 pm
Location: Pune, India

Re: if($my->id) does not work in joomla 1.5.6

Post by coolparth » Fri May 22, 2009 3:23 am

IN Joomla 1.5 $my is not declared like in 1.0. You need to define it like i said earlier..

So your code would be :

$my =& JFactory::getUser();
//Followed by your code..
if($my->id>0){
echo "Login";
}else
{
echo "Not login";
}
Parth Lawate Director
Tekdi Web Solutions. http://www.tekdi.net
Techjoomla. http://www.techjoomla.com


Locked

Return to “Templates for Joomla! 1.5”