Saturday, October 17, 2009

How to get joomla User ID

Sometimes we need to get the joomla user ID while we we customization in joomla component, module or plug-in. from the following code below we will get the log-in user ID. it is very simple code:

echo "Hello";
echo " User: ";

$user =& JFactory::getUser();
$usr_id = $user->get('id');
echo $usr_id; // this is the log-in user ID :-)

//after getting the user ID you can run your custom code like example,

$q="select * from jos_mytest where cf_user_id='$usr_id'";



How to get joomla default menu or check whether the url is front page or not::
<?php  $menu = &JSite::getMenu();
if ($menu->getActive() == $menu->getDefault())
{ echo 'This is the front page'; } ?>

hope it will help you.


  1. What a great information you shared in this post! I have a question that how to configure Virtue mart?
    Virtue Mart Templates

  2. Hi, thanks for your great information! Well, it really seems so great.