WordPress Hooks

TypeRocket comes with a number of hooks to help you extend its core functionality.

Core Loaded

The typerocket_loaded hook runs during after_setup_theme, after TypeRocket core has been loaded, and before the TypeRocket registry is run.

This hook is designed to allow WordPress plugins to interact with TypeRocket.

add_action( 'typerocket_loaded', function() {
    // do stuff


The tr_model action hook runs after a model is constructed

add_action( 'tr_model', function($model) {
    // do stuff


The tr_model_fillable_{model} filter sets the fillable fields of a model. For example, the filter applied the PagesModel would have the name tr_model_fillable_pages.

add_filter('tr_model_fillable_pages', function($fillable, $model){
    return $fillable;
}, 10, 2);


tr_model_guard_{model} works the same as the fillable hook.

add_filter('tr_model_guard_pages', function($guard, $model){
    return $guard;
}, 10, 2);

Secure fields

Filter the fields when a model tries to secure the user input. This filter run after fillable and guard security has been run.

add_filter( 'tr_model_secure_fields', function($fields, $model) {
    return $fields;
}, 10, 2);


Return true if the REST API should be run.

add_filter( 'tr_rest_api_load', function($load, $resource, $itemId) {
    return $load;
}, 10, 3);

Return true if the REST API template should be loaded.

add_filter('tr_rest_api_template', function($load) {
    return $load;


Return the middleware stack for the current hook call or REST API request.

add_filter('tr_kernel_middleware', function($middleware, $request, $type) {
    return $middleware;
}, 10, 3);

Plugins Collection

Modify the plugins that should be loaded.

add_filter('tr_plugins_collection', function($collection){
    return $collection;


Return true to run the matrix API.

add_filter('tr_matrix_api_load', function($load, $group, $type, $formGroup) {
    return $load;
}, 10, 4);

Return true if the matrix API template should be loaded.

add_filter('tr_matrix_api_template', function($load) {
   return $load;