Help Center
Find answers or browse our knowledge base.
Latest Questions
PHP Hooks: What Are They & How to Use the Form
Welcome to the PHP Hooks Injection Form — where the magic happens. This beast lets you surgically insert your custom PHP code into core files (like class-user.php, bootloader.php, profile.php) without ever cracking them open with a text editor.
🤔 What is a PHP Hook?
Think of PHP hooks as strategic bookmarks in your Sngine files — spots where you can drop your code snippets to extend functionality, run actions, or override behaviors without modifying the original file manually.
Each hook is wrapped between two juicy markers like this:
// === marker: start:my_custom_hook === // your PHP code here // === marker: end:my_custom_hook ===
So next time Sngine updates, you’re not crying in the corner because you edited the core.
🛠️ Using the PHP Hooks Form
Here's how to master this like a ScriptsTribe wizard:
- Choose the File: Select which file you want to inject into. Options include:
bootloader.php– Want to fire something right when Sngine loads?class-user.php– Want to modify login/session/user methods?profile.php– Add profile page features or custom logic.- And any file under
/root,/includes, or/apis.
- Define Your Marker Name: Give your hook a unique name. This becomes the marker tag (so no funky characters, just keep it like
my_stats_hookorinject_login_check). - Choose the Position:
Before– Inject your code before a marker line.After– Inject right after a marker line.Replace– Blow up the line and drop your own code in its place.
- Set the Marker: Enter the text in the file that your hook should latch onto.
Example: if you're hooking after$posts = $user->get_posts(...), paste that full line in the Marker field. - Write Your Code: This is where you drop your PHP logic you wish to add the the file.
- Click Inject! The form will:
- Backup the file with a timestamped filename (just in case).
- Inject your code between
// === marker: start:your_marker ===andend. - Smile at you like a proud parent.
🚀 Export Your Hook to Another Site
Built something amazing? Want to copy it to your other Sngine-powered sites without reinventing the wheel? Here’s how:
- Every PHP hook you create is stored in a json file inside PluginSystem/phphooks folder
- That JSON contains everything — file, marker, position, and your code.
- Take that JSON to any other ScriptsTribe Plugin System site and just import it via the same PHP Hooks panel.
Boom — the exact same hook will be injected into the exact same spot on the new site. Share it with clients, sell it, or just brag about how awesome your hook is. No FTP. No copy-paste. Pure wizardry.
💡 Example Use Case
// Inject a hook in class-user.php to log every login file: includes/class-user.php marker: public function login( position: before your code: error_log("User attempting to login at " . date('Y-m-d H:i:s'));
🧼 Uninject Anytime
Want to remove your hook? Just go back to the PHP Hooks admin form, select the hook, and hit Uninject. It'll safely rip it out and restore the file to its pre-hook glory (thanks to the backup).
✅ Best Practices
- Use unique marker names to avoid collisions.
- Always test your hook in staging before going live.
- Don’t go injecting into loops or conditions unless you know what you're doing. You can break things 😅.
- Use JSON export/import to standardize your PHP logic across multiple Sngine projects.
Now go forth and hook all the things! 🎣 You’re now officially a core hacker — but safely, like a good citizen.
Was this answer helpful?
How could it be better?
What went wrong?