Skip to Content Skip to Menu

🌲 Merry Christmas! Great savings on Professional and Developer Memberships! Get 25% off now with code XMAS-2024!

"Before" events in a plugin

  • geeffland
  • geeffland
  • OFFLINE
  • Posts: 199
  • Thanks: 0
  • Karma: 233
19 years 6 days ago #2487 by geeffland
"Before" events in a plugin was created by geeffland
I have not seen the answer to my question in the plugin API manual so excuse me if it is buried in there somewhere

For a lot of events there is a "Before" and "After" version. I assume that the "Before" events are like those in many other languages so with that in mind...

If I call a Before event, say for registration or login, and in my code I determine that it should "cancel" and not continue with either the registration or login how do I pass this cancel message along so that it will gracefully dump out of the process it is in...

CB3PD Developer - CB Connector (formerly phpBB Connector) plugin

Please Log in or Create an account to join the conversation.

  • beat
  • beat
  • OFFLINE
  • Posts: 2174
  • Thanks: 463
  • Karma: 352
19 years 4 days ago #2582 by beat
Replied by beat on topic Re:
geeffland wrote:

I have not seen the answer to my question in the plugin API manual so excuse me if it is buried in there somewhere

For a lot of events there is a "Before" and "After" version. I assume that the "Before" events are like those in many other languages so with that in mind...

If I call a Before event, say for registration or login, and in my code I determine that it should "cancel" and not continue with either the registration or login how do I pass this cancel message along so that it will gracefully dump out of the process it is in...


Here a small example:

[code:1]
$_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
*/
function pluginExampleBeforeUserRegistration(&$user,&$cbUse) {
global $_POST, $_PLUGINS;

if ($_POST == $_POST) {
$_PLUGINS->raiseError(0);
$_PLUGINS->_setErrorMSG("Password has to be different from username!"«»);
return false;
}
return true;
}
[/code:1]

Beat - Community Builder Team Member

Before posting on forums: Read FAQ thoroughly -- Help us spend more time coding by helping others in this forum, many thanks :)
CB links: Our membership - CBSubs - Templates - Hosting - Forge - Send me a Private Message (PM) only for private/confidential info

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum