Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 为Joomla社区生成器开发插件_Php_Joomla_Joomla Extensions - Fatal编程技术网

Php 为Joomla社区生成器开发插件

Php 为Joomla社区生成器开发插件,php,joomla,joomla-extensions,Php,Joomla,Joomla Extensions,我正在使用Joomla的模块社区生成器,并且我在源代码中看到触发了onAfterUserRegistration事件。所以我试着为这次活动开发一个插件。以下是我所做的: <?php defined('_JEXEC') or die( 'Restricted access' ); jimport('joomla.plugin.plugin'); class plgUserRegistration extends JPlugin { function plgUserRegistra

我正在使用Joomla的模块社区生成器,并且我在源代码中看到触发了
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 !
    }
}

以下是一些建议:

  • 检查插件是否已启用
  • 插件组必须是用户,请检查

  • 以下是一些建议:

  • 检查插件是否已启用
  • 插件组必须是用户,请检查

  • 有点晚了,但也许它可以帮助其他人。您必须创建CB插件,而不是Joomla插件。 您可以参考CB插件框架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;
    }
    

    希望这有点晚,但也许它可以帮助其他人。您必须创建CB插件,而不是Joomla插件。 您可以参考CB插件框架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;
    }
    

    希望这有帮助

    我对Joomla一无所知,但似乎您只是在这里定义一个类。在大多数插件系统中,您需要实际注册插件,然后让插件订阅事件。这两个步骤我都看不到。Joomla中需要它们吗?是的,它们是需要的,但是你通过后端完成了,我已经完成了。我对Joomla一无所知,但似乎你只是在这里定义了一个类。在大多数插件系统中,您需要实际注册插件,然后让插件订阅事件。这两个步骤我都看不到。Joomla需要它们吗?是的,它们是需要的,但你通过后端完成了,我已经完成了。除了Gaurav的回答,他说的“插件启用”,意味着你必须在插件表中创建一个数据库行。除了Gaurav的回答,他说的“插件启用”,他的意思是你必须在plugin表中创建一个数据库行。我很努力地寻找CB plugin Framework API文档,但结果是空的。现在它可能在付费墙后面。我已经非常努力地寻找CB插件框架API文档,但结果是空的。现在可能在工资墙后面。