0

我为 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>
4

1 回答 1

0

我不确定以下两个中的哪一个解决了它,但是

a) 我将我的插件重命名为 plgUserPluginname 而不是 plgUserPluginName (小 n 代表名称) b) 我将可访问性从 Registered 更改为 Public

现在正在调用它!

于 2012-10-02T10:58:04.717 回答