Pages

Monday, August 8, 2011

How to get current joomla User ID and Username

For joomla starter, sometime we need to get joomla user ID and username to customize in joomla component, plugins or modules. for that we have to write simple code

<?php
    $user =& JFactory::getUser();   
    $usr_id = $user->get('id');   
    echo "Current Login User Id : ".$usr_id;  // this is the log-in user ID :-)   
    
    $usr_name$user->get('username');   
    echo "Current Login User Name : ".$usr_name;  // this is the log-in username :-)  

    //after getting the user ID and username you can run your custom code
?>

No comments:

Post a Comment