If you want your component function to be accessed by your user prior to login programmatically you can use the following code:
|
public function toLogin($msg = "") { if (!$msg) $msg = JText::_('JGLOBAL_YOU_MUST_LOGIN_FIRST'); $app = &JFactory::getApplication(); $uri = JFactory::getURI(); $app->redirect('index.php?option=com_users&view=login&return=' . base64_encode($uri), $msg); return; } |
You can include the function in your helper class
helpers/yourcomponent.php
You can call the function in your MVC code with the following instructions:
|
$user = JFactory::getUser(); if (!$user->get('id')) { JLoader::register('yourcomponentHelper', JPATH_COMPONENT.'/helpers/yourcomponent.php'); yourcomponentHelper::toLogin(); } |



