Saturday 13 April 2013

Joomla code that you should know.

HOW TO GET LOGIN ID

<?php
$user=& JFactory::getuser();
$id2=$user->get('id');
if($id2>0){

}else{
 $mainframe =& JFactory::getApplication('site');
 $mainframe->redirect($indexpath."/index.php");
}
?>

HOW TO GET USER INFO
function  getUserValue($id,$field){

  $db   =& JFactory::getDBO();
  $query="SELECT $field from #__users Where id=".$id;
  $db->setQuery($query);
  $result=$db->loadObject($field);
  
  return str_replace("<br />","\n",$result->$field);

}/*How to show the function data*/
<?php echo getUserValue($this->user->get('id'),'address');?>"
<?php echo getUserValue($id1,'homepage');?>

how to call the function :-

No comments:

Post a Comment