我为 Joomla 编写了一个小型用户插件!这应该根据用户组更改登录时的返回 url。但是,它甚至没有被调用。我究竟做错了什么?
class plgUserPluginName extends JPlugin
{
/**
* This method should handle any login logic and report back to the subject
*
* @param array $user Holds the user data
* @param array $options Array holding options (remember, autoregister, group)
*
* @return boolean True on success
* @since 1.5
*/
public function onUserLogin($user, $options = array())
{
$user = JFactory::getUser();
$db = JFactory::getDBO();
$db->setQuery(
'SELECT link_id FROM '.$db->quoteName('#__mt_links') .
' WHERE '.$db->quoteName('user_id').' = '.$db->quote($user->id)
);
$link_id = $db->loadResult();
if(!$link_id){
$db->setQuery(
'SELECT group_id FROM '.$db->quoteName('#__user_usergroup_map') .
' WHERE '.$db->quoteName('user_id').' = '.$db->quote($user->id)
);
$group_id = $db->loadResult();
if($group_id == somegroupid) $options['return'] = 'abc';
elseif($group_id == someothergroupid) $options['return'] = 'xyz';
}
return true;
}
}
我的xml是:
<?xml version="1.0" encoding="utf-8"?>
<extension version="2.5" type="plugin" group="user">
<name>plg_user_pluginname</name>
<version>1.0.0</version>
<description>PLG_USER_PLUGINNAME_XML_DESCRIPTION</description>
<files>
<filename plugin="pluginname">pluginname.php</filename>
<filename>index.html</filename>
</files>
<languages>
<language tag="en-GB">en-GB.plg_user_pluginname.ini</language>
<language tag="en-GB">en-GB.plg_user_pluginname.sys.ini</language>
</languages>
<config>
</config>
</extension>