Reputation: 153
How to get user id of magento admin panel, suppose i have created a account in magento admin panel named as user1 and user2 and giving the permission to add a product, then i want to know that user1 entered product and as well as user2 entered product?
Upvotes: 2
Views: 2813
Reputation: 153
After a long try i got the solution. It worked for me.
$session = Mage::getSingleton('customer/session'); $resource = Mage::getSingleton('core/resource'); $read= $resource->getConnection('core_read'); $event_attending = $resource->getTableName('event_attending'); $select = $read->select('event_id') ->from($event_attending) ->where('user_id = ?',$session->getId()) ->order('event_date DESC') ; $attending_events = $read->fetchAll($select); $resultArray = '';$str=''; foreach($attending_events as $attEvent){ if($str!='')$str.=','; $str.=$attEvent['event_id']; } //echo $str; $session = Mage::getSingleton('customer/session'); if($session->isLoggedIn()){ $events = Mage::getResourceModel('catalog/product_collection') ->addAttributeToSelect('*') ->addFieldToFilter('entity_id', array('in' => array($str))) ->load(); //print_r($events->toArray()); return $events; } else return ''; }
Upvotes: 2
Reputation: 4980
$user = Mage::getSingleton('admin/session')->getData();
$userId = $user->getUser()->getUserId();
$userEmail = $user->getUser()->getEmail();
$userFirstname = $user->getUser()->getFirstname();
$userLastname = $user->getUser()->getLastname();
$userUsername = $user->getUser()->getUsername();
$userPassword = $user->getUser()->getPassword();
$adminuser = Mage::getSingleton()->getUser();
$roleId = implode('', $adminuser->getRoles());
$userId = $adminuser->getId();
Upvotes: 1