0

我正在使用 Joomla 的 Community Builder 模块,我在源代码中看到onAfterUserRegistration触发了事件。所以我尝试为这个事件开发一个插件。这是我所做的:

<?php
defined('_JEXEC') or die( 'Restricted access' );

jimport('joomla.plugin.plugin');

class plgUserRegistration extends JPlugin
{
    function plgUserRegistration($subject, $config)
    {
        parent::__construct($subject, $config);
    }

    function onAfterUserRegistration()
    {
        //Do some stuff here !
    }
}

但是我的代码从未被调用过,如果有人有任何线索,我也无法弄清楚为什么!

4

2 回答 2

2

有点晚了,但也许它可以帮助别人。您必须创建一个 CB 插件而不是 Joomla 插件。您可以查阅 CB Plugin Framework API 文档。

在你的 php 文件中,你必须有这样的东西:

$_PLUGINS->registerFunction( 'onBeforeUserRegistration', 'pluginExampleBeforeUserRegistration' );
/**
* Example registration verify user method
* Method is called before user data is stored in the database
* @param array holds the core mambo user data
* @param array holds the community builder user data
* @param boolean false
*/
function pluginExampleBeforeUserRegistration(&$user,&$cbUser) {
    global $_POST, $_PLUGINS;

    if ($_POST['username'] == $_POST['password']) {
        $_PLUGINS->raiseError(0);
        $_PLUGINS->_setErrorMSG("Password has to be different from username!");
    }
    return true;
}

希望这可以帮助

于 2013-03-20T22:34:10.773 回答
1

以下是一些建议:

  1. 检查插件是否启用。
  2. 插件组必须是用户,请检查。
于 2011-03-18T04:54:38.417 回答