I'm in the midst of hacking a plugin called plg_FirstLoginRedirct. Originally written for J1.5, I'm attempting to make it 2.5 compatible, however, my knowledge of PHP and the Joomla API is limited. I think I am nearly there, I just need a little help to get over the line. This is a function which I believe is highly sought after. The plugin is GPL'd and I'd be happy to add your name to the credits and re-publish a new version if you lend me a hand.
The original plugin can be found here http://construct-framework.com/redirect ... gin-plugin
Below is my modified code. The plugin simply checks the user's last login date and if it is not set (all 0's) sets it and redirects appropriately.
It currently causes my local Apache install to drop the connection when logging in while the plugin is active. Any comments/code help/pointers would be much appreciated.
Cheers
Code: Select all
// no direct access
defined('_JEXEC') or die;
jimport( 'joomla.plugin.plugin' );
class plgUserRedirectFirstLogin extends JPlugin
{
function onUserLogin($user, $options)
{
$app =& JFactory::getApplication();
$user =& JFactory::getUser();
if ($user->get('guest') != 1 && $user->lastvisitDate == "0000-00-00 00:00:00")
{
$user->setLastVisit();
$date = JFactory::getDate();
$user->lastvisitDate = $date->toMySQL();
$app->redirect($this->params->get('destination'));
return true;
}
}
}