简体   繁体   中英

Develop a plugin for Community Builder for Joomla

I am using the module Community Builder for Joomla and I have seen in the source code that the onAfterUserRegistration event is triggered. So I tried to develop a plugin for this event. Here is what I have done :

<?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 !
    }
}

But my code is never called and I cant figure out why, if someone as any clue!

A little late but maybe it can help someone else. You must create a CB plugin and not a Joomla plugin. You can consult the CB Plugin Framework API documentation.

In your php file, you must have something like that :

$_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;
}

hope this helps

Here are some suggestions:

  1. Check whether the plugin is enabled or not.
  2. The plugin group must be User, please check that also.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM