| 

Our Tutorials

Tutorial Library

Using CB Triggers

Tutorials - API usage

User Rating: / 0
PoorBest 

Community Builder has an assortment of triggers which can be used to alter CB data or even Joomla data without hacking the code. There are multiple use scenarios for these triggers. You can use them in modules, components, bots, plugins, or essentially anything you include the CB API in.

To initiate a trigger you'll need to add the call for it. At the top of your php file add the following just below direct access check. You must ALWAYS include the Global for $_PLUGINS to avoid any errors.

1
2
global $_PLUGINS;
$_PLUGINS->registerFunction( 'TRIGGER', 'FUNCTION', 'CLASS' );


The format above is mandatory with the exception of Class, This allows you to call Function when Trigger is executed. Class allows you to trigger Function in Class. Some triggers pass variables upon execution. You can specify these variables at the end of the Function with the format of Function( $var1, $var2 ). Optionally you can ignore this and specify the variables in your function it self such as:

function Function( $var1, $var2 ) {


Now that the formatting and preparation is understood you'll need to know the list of available triggers. Below is a rather large list of triggers found all throughout CB which are all available for your usage. Keep in mind some due contain variables; generally all have the starting variable of $user. Each trigger is seperated by the File they are executed in, this means there could be duplicates in the list.

cb.authentication.php
1
2
3
4
5
6
7
8
9
$_PLUGINS->trigger( 'onBeforeLogin', array( &$username, &$password ) );
$_PLUGINS->trigger( 'onLoginAuthentication', array( &$username, &$password, &$row, $loginType, &$foundUser, &$stopLogin, &$resultError, &$messagesToUser, &$alertmessages, &$return ) );
$_PLUGINS->trigger( 'onDuringLogin', array( &$row, 1, &$returnPluginsOverrides ) );
$_PLUGINS->trigger( 'onBeforeFirstLogin', array( &$row, $username, $password, &$return ));
$_PLUGINS->trigger( 'onDoLoginNow', array( $username, $password, $rememberMe, &$row, &$loggedIn, &$resultError, &$messagesToUser, &$alertmessages, &$return ) );
$_PLUGINS->trigger( 'onAfterLogin', array( &$row, $loggedIn ) );
$_PLUGINS->trigger( 'onBeforeLogout', array( $myUser ) );
$_PLUGINS->trigger( 'onDoLogoutNow', array( &$loggedOut, &$myUser, &$return ) );
$_PLUGINS->trigger( 'onAfterLogout', array( $myUser, true ) );

 

cb.list.php
1
2
3
4
$_PLUGINS->trigger( 'onStartUsersList', array( &$listid, &$row, &$search, &$limitstart, &$limit ) );
$_PLUGINS->trigger( 'onAfterUsersListFieldsSql', array( &$columns, &$allFields, &$tableReferences ) );
$_PLUGINS->trigger( 'onBeforeUsersListBuildQuery', array( &$tablesSQL, &$joinsSQL, &$tablesWhereSQL ) );
$_PLUGINS->trigger( 'onBeforeUsersListQuery', array( &$queryFrom, 1, $listid ) );

 

cb.tables.php
1
2
3
4
5
6
7
8
9
10
11
$_PLUGINS->trigger( 'onBeforeUserUpdate', array( &$this, &$this, &$oldUserComplete, &$oldUserComplete ) );
$_PLUGINS->trigger( 'onBeforeNewUser', array( &$this, &$this, false ) );
$_PLUGINS->trigger( 'onBeforeUpdateUser', array( &$this, &$this, &$oldUserComplete ) );
$_PLUGINS->trigger( 'onBeforeUserRegistration', array( &$this, &$this ) );
$_PLUGINS->trigger( 'onSaveUserError', array( &$this, $this->_error, $reason ) );
$_PLUGINS->trigger( 'onAfterUserUpdate', array( &$this, &$this, $oldUserComplete ) );
$_PLUGINS->trigger( 'onAfterNewUser', array( &$this, &$this, false, true ) );
$_PLUGINS->trigger( 'onAfterUpdateUser', array( &$this, &$this, $oldUserComplete ) );
$_PLUGINS->trigger( 'onAfterUserRegistration', array( &$this, &$this, true ) );
$_PLUGINS->trigger( 'onBeforeUserConfirm', array( $this ) );
$_PLUGINS->trigger( 'onAfterUserConfirm', array( $this, true ) );

 

comprofiler.class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$_PLUGINS->trigger( 'onBeforeUserActive', array( &$user, $ui, $cause, $mailToAdmins, $mailToUser ) );
$_PLUGINS->trigger( 'onUserActive', array( &$user, $ui, $cause, $mailToAdmins, $mailToUser ) );
$_PLUGINS->trigger( 'onBeforeDeleteUser', array( $user ) );
$_PLUGINS->trigger( 'onAfterDeleteUser', array( $user, true ) );
$_PLUGINS->trigger( 'onAfterTabsFetch', array( &$this->tabsToDisplay[$position], &$user, 'profile' ) );
$_PLUGINS->trigger( 'onPrepareMenus', array( &$user ) );
$_PLUGINS->trigger( 'onAfterPrepareViewTabs', array( &$this->tabsContents, &$this->tabsToDisplay[$position], &$user, $position, $tabid ) );
$_PLUGINS->trigger( 'onBeforeEditATab', array( &$oContent, &$oTab, &$user, &$postdata, $output, $formatting, $reason, $tabbed ) );
$_PLUGINS->trigger( 'onAfterEditATab', array( &$oContent, &$oTab, &$user, &$postdata, $output, $formatting, $reason, $tabbed ) );
$_PLUGINS->trigger( 'onAfterTabsFetch', array( &$tabsCache, &$user, $reason ) );
$_PLUGINS->trigger( 'onAfterFieldsFetch', array( &$fields, &$user, $reason, $tabid, $fieldIdOrName ) );
$_PLUGINS->trigger( 'onBeforeAddConnection', array( $this->referenceid, $connectionid, $ueConfig['useMutualConnections'], $ueConfig['autoAddConnections'], &$umsg ) );
$_PLUGINS->trigger( 'onAfterAddConnection', array( $this->referenceid, $connectionid, $ueConfig['useMutualConnections'], $ueConfig['autoAddConnections'] ) );
$_PLUGINS->trigger( 'onBeforeRemoveConnection', array( $userid, $connectionid, $ueConfig['useMutualConnections'], $ueConfig['autoAddConnections'] ) );
$_PLUGINS->trigger( 'onAfterRemoveConnection', array( $userid, $connectionid, $ueConfig['useMutualConnections'], $ueConfig['autoAddConnections'] ) );
$_PLUGINS->trigger( 'onBeforeDenyConnection', array( $userid, $connectionid, $ueConfig['useMutualConnections'], $ueConfig['autoAddConnections'] ) );
$_PLUGINS->trigger( 'onAfterDenyConnection', array( $userid, $connectionid, $ueConfig['useMutualConnections'], $ueConfig['autoAddConnections'] ) );
$_PLUGINS->trigger( 'onBeforeAcceptConnection', array( $userid, $connectionid, $ueConfig['useMutualConnections'], $ueConfig['autoAddConnections'] ) );
$_PLUGINS->trigger( 'onAfterAcceptConnection', array( $userid, $connectionid, $ueConfig['useMutualConnections'], $ueConfig['autoAddConnections'] ) );

 

controller.default.php
1
2
3
4
5
6
7
8
9
10
$_PLUGINS->trigger( 'onBeforeUserApproval', array( $row, $approved ) );
$_PLUGINS->trigger( 'onAfterUserApproval', array( $row, $approved, true ) );
$_PLUGINS->trigger( 'onBeforeUserBlocking', array( $row, $actionValue ) );
$_PLUGINS->trigger( 'onBeforeSyncUser', true );
$_PLUGINS->trigger( 'onAfterSyncUser', true );
$_PLUGINS->trigger( 'onAfterCheckCbDb', true );
$_PLUGINS->trigger( 'onAfterCheckCbFieldsDb', true );
$_PLUGINS->trigger( 'onBeforeFixDb', array( $dryRun ) );
$_PLUGINS->trigger( 'onAfterFixDb', array( $dryRun ) );
$_PLUGINS->trigger( 'onBeforeFixFieldsDb', array( $dryRun ) );

 

controller.users.php
1
2
3
4
5
$_PLUGINS->trigger( 'onBeforeBackendUsersListBuildQuery', array( &$tablesSQL, &$joinsSQL, &$tablesWhereSQL, $option ) );
$_PLUGINS->trigger( 'onAfterBackendUsersList', array( 1, &$rows, &$pageNav, &$search, &$lists, $option, $select_tag_attribs ) );
$_PLUGINS->trigger( 'onBeforeBackendUsersEmailForm', array( &$rows, &$pageNav, &$search, &$lists, &$cid, &$emailSubject, &$emailBody, &$inputTextExtras, &$select_tag_attribs, $simulationMode, $option ) );
$_PLUGINS->trigger( 'onBeforeBackendUsersEmailStart', array( &$rows, $total, $search, $lists, $cid, &$emailSubject, &$emailBody, &$inputTextExtras, $simulationMode, $option ) );
$_PLUGINS->trigger( 'onBeforeBackendUserEmail', array( &$user, &$emailSubject, &$emailBody, $mode, &$extraStrings, $simulationMode ) );

 

plugin.class.php
1
2
3
$_PLUGINS->trigger( 'onInputFieldHtmlRender', array( $htmlInput, $htmlIcons, $this, $field, $user, $reason, $tag, $type, $inputName, $value, $additional, $htmlDescription, $allValues, $displayFieldIcons, $oReq ) );
$_PLUGINS->trigger( 'onFieldIcons', array( &$this, &$field, &$user, $output, $reason, $tag, $type, $value, $additional, $allValues, &$displayFieldIcons, $required ) );
$_PLUGINS->trigger( 'onLogChange', array( 'update', 'user', 'field', &$user, &$this->_plugin, &$field, $oldValues, $newValues, $reason ) );

 

view.user.php
1
$_PLUGINS->trigger( 'onBeforeUserProfileEditDisplay', array( &$user, 2 ) );

 

cb.core.php
1
2
$_PLUGINS->trigger( 'onBeforeUserAvatarUpdate', array( &$user, &$user, $isModerator, &$value['tmp_name'] ) );
$_PLUGINS->trigger( 'onAfterUserAvatarUpdate', array( &$user, &$user, $isModerator, $newFileName ) );

 

comprofiler.html.php
1
2
3
4
5
6
7
8
9
10
11
$_PLUGINS->trigger( 'onBeforeEmailUserForm', array( &$rowFrom, &$rowTo, 1 ) );
$_PLUGINS->trigger( 'onAfterEmailUserForm', array( &$rowFrom, &$rowTo, &$warning, 1 ) );
$_PLUGINS->trigger( 'onBeforeUserProfileEditDisplay', array( &$user, 1 ) );
$_PLUGINS->trigger( 'onAfterUserProfileEditDisplay', array( $user, $tabcontent ) );
$_PLUGINS->trigger( 'onBeforeUserProfileRequest', array( &$user, 1 ) );
$_PLUGINS->trigger( 'onBeforeUserProfileDisplay', array( &$user, 1, $cbUserIsModerator, $cbMyIsModerator ) );
$_PLUGINS->trigger( 'onAfterUserProfileDisplay', array( $user,true ) );
$_PLUGINS->trigger( 'onBeforeDisplayUsersList', array( &$row, &$users, &$columns, &$allFields, &$lists, $listid, &$search, &$option_itemid, 1 ) );
$_PLUGINS->trigger( 'onLostPassForm', array( 1 ) );
$_PLUGINS->trigger( 'onBeforeLoginFormDisplay', array( &$postvars, $regErrorMSG ) );
$_PLUGINS->trigger( 'onBeforeRegisterFormDisplay', array( &$user, $regErrorMSG ) );

 

comprofiler.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$_PLUGINS->trigger( 'onBeforeEmailUser', array( &$rowFrom, &$rowTo, 1 ) );
$_PLUGINS->trigger( 'onBeforeUserAvatarUpdate', array( &$row, &$row, $isModerator, &$_FILES['avatar']['tmp_name'] ) );
$_PLUGINS->trigger( 'onAfterUserAvatarUpdate', array( &$row, &$row, $isModerator, $newFileName ) );
$_PLUGINS->trigger( 'onStartNewPassword', array( &$checkusername, &$confirmEmail ) );
$_PLUGINS->trigger( 'onBeforeUsernameReminder', array( $userIdUsername->id, &$subject, &$message ) );
$_PLUGINS->trigger( 'onAfterUsernameReminder', array( &$result, &$res ) );
$_PLUGINS->trigger( 'onBeforeNewPassword', array( $user_id, &$newpass, &$subject, &$message ) );
$_PLUGINS->trigger( 'onNewPassword', array( $user_id, $newpass ) );
$_PLUGINS->trigger( 'onBeforeRegisterForm', array( $option, $emailpass, &$regErrorMSG, $fieldsQuery ) );
$_PLUGINS->trigger( 'onStartSaveUserRegistration', array() );
$_PLUGINS->trigger( 'onAfterUserRegistrationMailsSent', array( &$userComplete, &$userComplete, &$messagesToUser, $ueConfig['reg_confirmation'], $ueConfig['reg_admin_approval'], true ) );
$_PLUGINS->trigger( 'onBeforeUserApproval', array( $user, true ) );
$_PLUGINS->trigger( 'onAfterUserApproval', array( $user, true, true ) );
$_PLUGINS->trigger( 'onBeforeUserApproval', array( $row, false ) );
$_PLUGINS->trigger( 'onAfterUserApproval', array( $row, false, true ) );
Professional Member
Professional badge
As a Professional member you get all the Advanced privileges (CB detailed documentation, 17+ CB Add-ons, 11 GroupJive) and access to our same or next business day response time support forum for all your websites and our 26+ Incubator add-ons! That's a lot of add-ons that you can use on all your websites for ever!

 

Only 119 € for 12 months


Go Professional Now!