- b2evolution CMS User Manual
- Developer Reference
- Plugins
- Plugin development
- List of Plugin Hooks
List of Plugin Hooks
Below is the list of all plugin Hooks as of b2evolution 6.7.8.
For more information about each method, look at the source code:
- in the "test plugin" class (greatly enhanced in v6.7.8)
- in the Plugin class itself.
Plugin information (settings, DB layout, ..):
GetDependencies()
Tells the Plugins class, what your Plugin depends on.
GetDbLayout()
This method should return a plugin DB schema, consisting of a list of CREATE TABLE queries.
For table name use a code like $this->get_sql_table( 'test_table_name' )
.
It returns a string evo_plugin_test_123_test_table_name
(evo_
is table prefix, test
- plugin class name, 123
- plugin ID).
GetDefaultSettings()
Tells the Plugins class, what settings your Plugin provides.
If you return a list of setting definitions here, your Plugin will get a member object Settings, which you can use.
These settings are automatically editable in the back-office.
GetDefaultUserSettings()
Define the per-user settings of the plugin here. These can then be edited by each user.
You can access them in the plugin through the object member e.g.: $this->UserSettings->get( 'my_param' );
GetExtraEvents()
This method gets asked when plugins get installed and allows you to return a list of extra events, which your plugin triggers itself (e.g. through $Plugins->trigger_event()
).
GetHtsrvMethods()
Override this method to define methods/functions that you want to make accessible through /htsrv/call_plugin.php
, which allows you to call those methods by HTTP request.
Example code of this method is return array( 'test_action' );
, to call this action use URL which is generated by code:
$htsrv_plugin_url = $this->get_htsrv_url( 'test_action', array( 'param_1' => 'value_1' ) );
The expected execution code must be written in method of the plugin function htsrv_test_action( $params )
.
GetCronJobs()
This method gets asked for a list of cronjobs that the plugin provides.
ExecCronJob()
Execute/handle a cron job, which has been scheduled by the admin out of the list that the Plugin provides in GetCronJobs()
.
get_custom_setting_definitions()
Define here default custom settings that are to be made available in the back-office for Collections, Private Messages and Email Campaigns.
See GetDefaultSettings()
for return array format.
get_coll_setting_definitions()
Adds collection plugin settings to array of get_custom_setting_definitions()
.
If this method returns a non-empty value then a Settings form will be included in per-Collection Plugin Settings screen.
get_msg_setting_definitions()
Adds messages plugin settings to array of get_custom_setting_definitions()
.
If this method returns a non-empty value then a Settings form will be included in Message Plugin Settings screen
get_email_setting_definitions()
Adds email campaign plugin settings to array of get_custom_setting_definitions()
.
If this method returns a non-empty value then a Settings form will be included in Email Campaign Plugin Settings screen
get_widget_param_definitions()
Get definitions for widget specific editable params.
See GetDefaultSettings()
for return array format.
get_widget_cache_keys()
Get keys for block/widget caching. For return array form read Widget Caching.
Admin/back-office events:
AdminAfterEvobarInit()
Event handler gets invoked in skin file toolbar.inc.php
after the menu structure is built.
AdminAfterMenuInit()
Event handler gets invoked in /admin.php
for every back-office page after the menu structure is built. You could use the $AdminUI
object to modify it.
AdminEndHtmlHead()
Event handler is called when ending the back-office html <head>
section.
AdminAfterPageFooter()
Event handler is called right after displaying the back-office page footer.
AdminDisplayEditorButton()
Event handler is called when displaying editor buttons (in back-office) under the edit forms of either Item or Comment or Email Campaign.
DisplayEditorButton()
Event handler is called when displaying editor buttons (in front-office) under the edit forms of either Item or Comment.
AdminDisplayToolbar()
Event handler is called when displaying editor toolbars on Item form (in front-office and back-office).
AdminToolAction()
Event handler is called when handling actions for the Tools menu in back-office.
AdminToolPayload()
Event handler is called when displaying the block in the Tools menu in back-office.
AdminTabAction()
Event handler gets invoked when our tab is selected.
You should catch (your own) params (using param()
) here and do actions(but no output!).
AdminTabPayload()
Event handler gets invoked when our tab is selected and should get displayed.
Do your output here.
AdminBeginPayload()
Event handler gets invoked before the main payload in the back-office.
WidgetBeginSettingsForm()
Event handler is called at the beginning of the "Edit wdiget" form on back-office.
WidgetEndSettingsForm()
Event handler is called at the end of the "Edit wdiget" form on back-office.
Skin events:
BeforeBlogDisplay()
Event handler is called before a collection gets displayed (in _blog_main.inc.php
).
BeforeBlockableAction()
Event handler gets invoked when an action request was called which should be blocked in specific cases.
InitMainList()
Event handler is called when a $MainList
object gets created.
SkinBeginHtmlHead()
Event handler is called at the beginning of the skin’s HTML <head>
section.
SkinEndHtmlHead()
Event handler is called at the end of the skin’s HTML <head>
section.
SkinBeginHtmlBody()
Event handler is called at the beginning of the skin’s HTML <body>
section.
SkinEndHtmlBody()
Event handler is called at the end of the skin’s HTML <body>
section.
BeforeSkinWrapper()
Event handler is called before skin wrapper after toolbar.
SkinTag()
Event handler is called when a plugin widget gets called by its $this->code
.
If you provide this event, b2evolution will assume your plugin provides a widget and list it in the "Available widgets" list.
GetProvidedSkins()
Event handler gets asked about a list of skin names that the plugin handles.
If one of the skins returned gets called through the "skin=X" URL param, the Plugin::DisplaySkin()
method of your plugin gets called.
DisplaySkin()
Event handler: Display a skin. Use Plugin::GetProvidedSkins()
to return a list of names that you register.
(Un)Install / (De)Activate events:
BeforeInstall()
Event handler is called before the plugin is going to be installed.
AfterInstall()
Event handler is called after the plugin has been installed.
BeforeUninstall()
Event handler is called before the plugin is going to be un-installed.
BeforeUninstallPayload()
Event handler gets invoked to display the payload before uninstalling the plugin.
BeforeEnable()
Event handler is called when the admin tries to enable the plugin, changes its configuration/settings and after installation.
Use this, if your plugin needs configuration before it can be used.
BeforeDisable()
Event handler: Your plugin gets notified here, just before it gets disabled.
You cannot prevent this, but only clean up stuff, if you have to.
PluginVersionChanged()
Event handler is called when we detect a version change (in Plugins::register()
).
Use this for your upgrade needs.
Collection events:
AfterCollectionInsert()
Event handler is called at the end of Blog::dbinsert()
inserting a collection into the database, which means it has been created.
AfterCollectionUpdate()
Event handler is called at the end of Blog::dbupdate()
updating a collection in the database.
AfterCollectionDelete()
Event handler is called at the end of Blog::dbdelete()
deleting a collection from the database.
GetCollectionKinds()
Event handler to define collection kinds, their names and description.
Define collection settings in Plugin::InitCollectionKinds()
method of your plugin.
Note: You can change default collection kinds $params['kinds']
(which get passed by reference).
InitCollectionKinds()
Event handler to define collection settings by its kind. Use get_collection_kinds()
to return an array of available collection kinds and their names.
Define new collection kinds in Plugin::GetCollectionKinds()
method of your plugin.
Note: You have to change $params['Blog']
(which gets passed by reference).
Item events:
RenderItemAsHtml()
Event handler is called when rendering item/post contents as HTML. (CACHED)
The rendered content will be cached and the cached content will be reused on subsequent displays.
Use DisplayItemAsHtml()
instead if you want to do rendering at display time.
Note: You have to change $params['data']
(which gets passed by reference).
RenderItemAsXml()
Event handler is called when rendering item/post contents as XML.
Note: You have to change $params['data']
(which gets passed by reference).
RenderItemAsText()
Event handler is called when rendering item/post contents other than XML or HTML.
Note: You have to change $params['data']
(which gets passed by reference).
DisplayItemAsHtml()
Event handler is called when displaying an item/post’s content as HTML.
This is different from RenderItemAsHtml()
, because it gets called on every display (while rendering gets cached).
DisplayItemAsXml()
Event handler is called when displaying an item/post’s content as XML.
This is different from RenderItemAsXml()
, because it gets called on every display (while rendering gets cached).
DisplayItemAsText()
Event handler is called when displaying an item/post’s content as text.
This is different from RenderItemAsText()
, because it gets called on every display (while rendering gets cached).
PrependItemUpdateTransact()
Event handler is called at the beginning of Item::dbupdate()
updating an item/post in the database.
AfterItemUpdate()
Event handler is called at the end of Item::dbupdate()
updating an item/post in the database.
PrependItemInsertTransact()
Event handler is called at the beginning of Item::dbinsert()
inserting an item/post in the database.
AfterItemInsert()
Event handler is called at the end of Item::dbinsert()
inserting a item/post into the database, which means it has been created.
AfterItemDelete()
Event handler is called at the end of Item::dbdelete()
deleting an item/post from the database.
AppendItemPreviewTransact()
Event handler is called when instantiating an Item for preview.
AdminDisplayItemFormFieldset()
Event handler is called at the end of the "Edit item" form to add new fields to the $params['Form']
on back-office.
DisplayItemFormFieldset()
Event handler is called at the end of the "Edit item" form to add new fields to the $params['Form']
on front-office.
AdminBeforeItemEditDelete()
Event handler is called before an item gets deleted (in the back-office).
AdminBeforeItemEditCreate()
Event handler is called before a new item gets created (in the back-office).
AdminBeforeItemEditUpdate()
Event handler is called before an existing item gets updated (in the back-office).
ItemCanComment()
Event handler gets asked if an item can receive comments.
ItemSendPing()
Event handler to send a ping about a new item.
DisplayTrackbackAddr()
Event handler is called to display the URL that accepts trackbacks for an item.
ItemApplyAsRenderer()
Event handler: Does your Plugin want to apply as a renderer for the item?
NOTE: this is especially useful for lazy Plugins, which would look at the content and decide, if they apply.
Comment events:
DisplayCommentToolbar()
Event handler is called when displaying editor toolbars on comment form.
AdminDisplayCommentFormFieldset()
Event handler is called at the end of the "Edit comment" form in back-office.
DisplayCommentFormFieldset()
Event handler is called at the end of the "Edit comment" form on front-office.
DisplayCommentFormButton()
Event handler is called in the submit button section of the front-office comment form.
CommentFormSent()
Event handler is called before at the beginning, if a comment form gets sent (and received).
Use this to filter input, e.g. the OpenID uses this to provide alternate authentication.
BeforeCommentFormInsert()
Event handler is called before a comment gets inserted through the public comment form.
AfterCommentFormInsert()
Event handler is called when a comment form has been processed and the comment got inserted into DB.
GetSpamKarmaForComment()
Event handler is called to ask the plugin for the spam karma of a comment/trackback.
This gets called just before the comment gets stored.
AfterCommentUpdate()
Event handler is called at the end of Comment::dbupdate()
updating a comment in the database.
AfterCommentInsert()
Event handler is called at the end of Comment::dbinsert()
inserting a comment into the database, which means it has been created.
AfterCommentDelete()
Event handler is called at the end of Comment::dbdelete()
deleting a comment from the database.
BeforeTrackbackInsert()
Event handler is called before a trackback gets recorded.
AfterTrackbackInsert()
Event handler gets called after a trackback has been recorded.
FilterCommentAuthor()
Event handler is called to filter the comment’s author name (collection name for trackbacks).
FilterCommentAuthorUrl()
Event handler is called to filter the comment’s author URL.
This may be either the URL only or a full link (A tag).
FilterCommentContent()
Event handler is called to filter the comment’s content.
Message events:
DisplayMessageToolbar()
Event handler is called when displaying editor toolbars for message.
DisplayMessageFormFieldset()
Event handler is called at the end of the front-office message form, which allows to send an email to a user/commentator.
DisplayMessageFormButton()
Event handler is called in the submit button section of the front-office message form.
MessageThreadFormSent()
Event handler is called before at the beginning, if a message of thread form gets sent (and received).
MessageFormSent()
Event handler is called when a message form has been submitted.
Add messages of category "error" to prevent the message from being sent.
MessageFormSentCleanup()
Event handler is called after a message has been sent through the public email form.
This is meant to cleanup generated data.
FilterMsgContent()
Event handler is called to filter the message’s content.
RenderMessageAsHtml()
Event handler is called when rendering message contents as HTML. (CACHED)
The rendered content will be cached and the cached content will be reused on subsequent displays.
Note: You have to change $params['data']
(which gets passed by reference).
Email campaign events:
DisplayEmailToolbar()
Event handler is called when displaying editor toolbars for email campaign.
EmailFormSent()
Event handler is called before at the beginning, if an email form gets sent (and received).
FilterEmailContent()
Event handler is called to filter the email’s content.
RenderEmailAsHtml()
Event handler is called when rendering email contents as HTML. (CACHED)
The rendered content will be cached and the cached content will be reused on subsequent displays.
Note: You have to change $params['data']
(which gets passed by reference).
Caching events:
CacheObjects()
Event handler is called to cache object data.
CachePageContent()
Event handler is called to cache page content (get cached content or request caching).
This method must build a unique key for the requested page (including cookie/session info) and start an output buffer, to get the content to cache.
CacheIsCollectingContent()
Event handler gets asked for if we are generating cached content.
This is useful to not generate a list of online users or the like.
BeforeThumbCreate()
This gets called before an image thumbnail gets created.
This is useful to post-process the thumbnail image (add a watermark or change colors).
Plugin settings:
PluginSettingsValidateSet()
Event handler is called before displaying or setting a plugin’s setting in the back-office.
PluginSettingsUpdateAction()
Event handler is called as action just before updating the Plugin::$Settings
plugin’s settings.
The "regular" settings from GetDefaultSettings()
have been set into Plugin::$Settings
, but get saved into DB after this method has been called.
PluginSettingsEditAction()
Event handler is called as action before displaying the "Edit plugin" form, which includes the display of the Plugin::$Settings
plugin’s settings.
PluginSettingsEditDisplayAfter()
Event handler is called after the form to edit the Plugin::$Settings
has been displayed.
Use this to add custom input fields (and catch them in PluginSettingsUpdateAction()
) or display custom output (e.g. a test link).
PluginUserSettingsValidateSet()
Event handler is called before displaying or setting a plugin’s user setting in the back-office.
PluginUserSettingsUpdateAction()
Event handler is called as action just before updating the Plugin::$UserSettings
plugin’s user settings.
The "regular" settings from GetDefaultUserSettings()
have been set into Plugin::$UserSettings
, but get saved into DB after this method has been called.
PluginUserSettingsEditAction()
Event handler is called as action before displaying the "Edit user" form, which includes the display of the Plugin::$UserSettings
plugin’s user settings.
PluginUserSettingsEditDisplayAfter()
Event handler is called after the form to edit the Plugin::$UserSettings
has been displayed.
Use this to add custom input fields (and catch them in PluginUserSettingsUpdateAction()
) or display custom output (e.g. a test link).
PluginCollSettingsUpdateAction()
Event handler is called as action just before updating plugin’s collection settings.
PluginMsgSettingsUpdateAction()
Event handler is called as action just before updating plugin’s messages settings.
PluginEmailSettingsUpdateAction()
Event handler is called as action just before updating plugin’s email campaign settings.
User related events, including registration and login (procedure):
AfterLoginAnonymousUser()
Event handler is called at the end of the login procedure, if the user is anonymous ($current_User
current User NOT set).
AfterLoginRegisteredUser()
Event handler is called at the end of the login procedure, if the $current_User
current User is set and the user is therefor registered.
AppendUserRegistrTransact()
Event handler is called when a new user has registered, at the end of the DB transaction that created this user.
AfterUserRegistration()
Event handler is called when a new user has registered and got created.
DisplayRegisterFormBefore()
Event handler is called at the begining of the "Register as new user" form.
DisplayRegisterFormFieldset()
Event handler is called at the end of the "Register as new user" form.
RegisterFormSent()
Event handler is called when a "Register as new user" form has been submitted.
You can cancel the registration process by Plugin::msg()
adding a message of type "error".
DisplayLoginFormFieldset()
Event handler is called at the end of the "Login" form.
LoginAttempt()
This event handler is called when a User attempts to log in.
This is useful for integrating b2evolution with another user base / user directory (for example LDAP, Facebook, etc…)
Typical usage: your code would first check if the user already exists in b2evo and if not, authenticate him against another DB. If a match is found, create the User account locally (in b2evo).
The (new or existing) User then gets automatically logged in.
You can prevent the user from logging in by adding a message of type "login_error" with Plugin::msg()
.
See the LDAP Plugin, which uses this event "extensively".
LoginAttemptNeedsRawPassword()
Event handler: your Plugin should return true here, if it needs a raw (un-hashed) password for the Plugin::LoginAttempt()
event.
If any Plugin returns true for this event, client-side hashing of the password is not used.
NOTE: this causes passwords to travel un-encrypted, unless SSL/HTTPS get used.
Logout()
Event handler is called when a user logs out.
DisplayValidateAccountFormFieldset()
Event handler is called at the end of the "Validate user account" form, which gets invoked if newusers_mustvalidate is enabled and the user has not been validated yet.
ValidateAccountFormSent()
Event handler is called when a "Validate user account" form has been submitted.
DisplayProfileFormFieldset()
Event handler is called at the end of the "User profile" form.
The corresponding action event is Plugin::ProfileFormSent()
.
ProfileFormSent()
Event handler is called before at the beginning, if a profile form gets sent (and received).
AlternateAuthentication()
Event handler is called at the end of the login process, if the user did not try to login (by sending "login" and "pwd"), the session has no user attached or only "login" is given.
AfterUserUpdate()
Event handler is called at the end of User::dbupdate()
updating an user account in the database, which means that it has been changed.
AfterUserInsert()
Event handler is called at the end of User::dbinsert()
inserting an user account into the database, which means it has been created.
AfterUserDelete()
Event handler is called at the end of User::dbdelete()
deleting an user from the database.
General events:
CaptchaPayload()
Event handler to inject payload for a captcha test.
CaptchaValidated()
Event handler to validate a captcha which payload was added through CaptchaPayload()
.
CaptchaValidatedCleanup()
Event handler is called after an action has been taken, which involved CaptchaPayload()
and CaptchaValidated()
.
AfterObjectInsert()
Event handler is called at the end of DataObject::dbinsert()
inserting an object in the database.
AfterObjectUpdate()
Event handler is called at the end of DataObject::dbupdate()
updating an object in the database.
AfterObjectDelete()
Event handler is called at the end of DataObject::dbdelete()
deleting an object from the database.
FilterIpAddress()
Event handler is called when an IP address gets displayed, typically in a protected area or for a privileged user, e.g. in the back-office statistics menu.
SessionLoaded()
Event handler is called after initializing plugins, DB, Settings, Hit, .. but quite early.
AfterPluginsInit()
Event handler is called right after initializing plugins. This is the earliest event you can use.
AfterMainInit()
Event handler is called at the end of _main.inc.php
. This is the the latest event called before collection initialization.
BeforeSessionsDelete()
Event handler is called before pruning sessions. The plugin can prevent deletion of particular sessions, by returning their IDs.
AppendHitLog()
Event handler is called when a hit gets logged, but before it gets recorded.
AfterFileUpload()
Event handler is called before an uploaded file gets saved on server.
GetUserFromCountrySuffix()
This method should return a string that used as suffix for the field "From Country" on the user profile page in the back-office.
GetAdditionalColumnsTable()
This method initializes an array that used as additional columns for the results table in the back-office.