Customizing SMF > Portals, Bridges, and Integrations

A guide to the SMF integration hooks

(1/5) > >>

Orstio:
One of the great things about SMF is the fact that it has integration hooks throughout the code at key points so that you can add integration functions in at those key points without actually modifying any SMF code at all.


Please note that the documentation about integration hooks for SMF 2.x can be found on the wiki at the page Integration hooks.



Added by emanuele: the information in this topic are still valid for SMF 1.1, that's why the topic is still sticky.

This topic will be a guide to the usages of these hooks.  I hope it serves useful.

Starting up the integration system
The hooks
integrate_pre_include
integrate_pre_load
integrate_verify_user
integrate_validate_login
integrate_login
integrate_logout
integrate_activate
integrate_fix_url
integrate_verify_password
integrate_reset_pass
integrate_delete_member
integrate_register
integrate_outgoing_email
integrate_personal_message
integrate_change_member_data
integrate_redirect
integrate_exit
integrate_whos_online

New in SMF 2.0:
integrate_create_topic
integrate_load_theme
integrate_ouput_error

Orstio:

There are numerous methods to start up the integration hook system.

Typically, when creating a bridge, I have SMF "wrapped" within the context of a CMS, so the startup is done in the CMS, as a part of the component/module that displays the forum.

I prefer to use the serialized constant method:


--- Code: ---//define the integration functions
define('SMF_INTEGRATION_SETTINGS', serialize(array(
'integrate_change_email' => 'change_email_function',
'integrate_change_member_data' => 'change_member_data_function',
'integrate_reset_pass' => 'reset_pass_function',
'integrate_exit' => 'exit_function',
'integrate_logout' => 'logout_function',
'integrate_outgoing_email' => 'outgoing_email_function',
'integrate_login' => 'login_function',
'integrate_validate_login' => 'validate_login_function',
'integrate_redirect' => 'redirect_function',
'integrate_delete_member' => 'delete_member_function',
'integrate_register' => 'register_function',
'integrate_pre_load' => 'pre_load_function',
'integrate_whos_online' => 'whos_online_function',
)));
--- End code ---

You will notice the format:
     'hook name' => 'function name'

The names of the hooks are defined in SMF code, and the function name can be whatever you want.  In fact, it could even be a native function of the system in which you are integrating.  This is very open-ended.

Alternatively, the 'hook name' => 'function name' can be entered into SMF's settings table with an installation query, as 'variable' => 'value', and the result will be the same.  In this case, you wouldn't need to define the SMF_INTEGRATION_SETTINGS constant; the values would be pulled from the settings table along with all of SMF's other settings.

Orstio:
Now that we've defined the functions that will be called whenever a hook event takes place, we need to know what these hooks are, and when they take place, and the expected input and output for each one.

This is a list of all the SMF integration hook names to date:

integrate_pre_include
integrate_pre_load
integrate_verify_user
integrate_validate_login
integrate_login
integrate_logout
integrate_activate
integrate_fix_url
integrate_verify_password
integrate_reset_pass
integrate_delete_member
integrate_register
integrate_outgoing_email
integrate_personal_message
integrate_change_member_data
integrate_redirect
integrate_exit
integrate_whos_online

The following posts will discuss each one in detail.

Orstio:
Used in file:  Load.php
Used in function:  reloadSettings

Variables passed to hook function:  None
Variables expected from hook function: None

Usage:  This hook actually calls a file, not a function.

e.g. 'integrate_pre_include' => 'integration.php'

This is the very first integration hook encountered in the workflow.  It is started immediately after the loading of the SMF settings.  So, if you need to include some scripting at the beginning of SMF, this can be done with this hook in a separate file, without any need for modifying the SMF code.

Example of use:  Information is needed from a separate system that needs to be started after SMF is loaded.

Orstio:
Used in file:  Load.php
Used in function:  reloadSettings

Variables passed to hook function:  None
Variables expected from hook function: None

Usage:  This hook is started immediately after the integrate_pre_include hook.  It serves much of the same type of purpose, but it calls a function rather than including a file.

Example of use:  Modifying SMF settings to match those of an integrated system.

Navigation

[0] Message Index

[#] Next page

Go to full version