Writing a Basic Plugin
April 12, 2019
Latest Security Audit
April 25, 2019

Plugin Hooks

 
 

When you create a plugin for UserSpice, you can use our plugin hooks to allow you to inject code on common pages without modifying the page itself. Basically when you do your install.php file for your plugin, put

$hooks['account.php']['bottom'] = 'hooks/accountbottom.php';
So list the page, the position and the link to the file that is the “include” on that page. Note that you can use the same include on multiple pages. There’s nothing wrong with also doing…
$hooks['join.php']['bottom'] = 'hooks/accountbottom.php';
if your include code is the same. Be sure to test your hooks because you can seriously break projects. Plugin hooks are automatically uninstalled when a plugin is uninstalled.

If you want to know exactly where a plugin hook will be in the code, visit the page referenced and look for the includeHook function like includeHook($hooks,'post');

The new ‘pre’ hook is usually included right below the getMyHooks() function.

Page pre post body form bottom Description
account.php Body is below gravitar. Bottom is bottom right.
admin.php?view=general Do form and post in one div or use the built in settings table AJAX
admin.php?view=social(v4.4) Do form and post in one div or use the built in settings table AJAX
join.php Form is inside /views/_join.php
login.php Post is just before validation passed so you can boot them.
user_settings.php