Develop a plugin for Community Builder for Joomla
I am using the module Community Bui开发者_JS百科lder 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:
- Check whether the plugin is enabled or not.
- The plugin group must be User, please check that also.
精彩评论