Hook a function to a specific filter.


<?php $app->hook->add_filter($hook, $function_to_add, $priority, $accepted_args); ?>


$hook: (string) (required) The name of the existing Filter to Hook the $function_to_add argument to.

$function_to_add: (callback) (required) The name of the function to be called when the custom Filter is applied.

$priority: (int) (optional) Used to specify the order in which the functions associated with a particular action are executed. Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action.

$accepted_args: (int) (optional) The number of arguments the hooked function accepts. Hooked functions can take extra arguments that are set when the matching apply_filter() call is run.

Return Values

The function returns true if the attempted function hook succeeds or false if not.


Filter to override the default department code dropdown list.

$app = \Liten\Liten::getInstance();

function my_function_dept_type($select, $typeCode)
    $select = '<select name="deptTypeCode" id="deptType" class="selectpicker form-control" data-style="btn-info" data-size="10" data-live-search="true" required>
            <option value="">&nbsp;</option>
            <option value="ADMIN"' . selected($typeCode, 'ADMIN', false) . '>' . _t('ADMIN - Administrative') . '</option>
            <option value="ACAD"' . selected($typeCode, 'ACAD', false) . '>' . _t('ACAD - Academic') . '</option>
            <option value="MAIN"' . selected($typeCode, 'MAIN', false) . '>' . _t('MAIN - Maintenance') . '</option>
    echo $select;
$app->hook->add_filter('dept_type', 'my_function_dept_type', 10, 2);

Change Log

Since 1.0.0

Source File

$app->hook->add_filter() is located in app/src/Hooks.php.

  • apply_filter()
  • add_filter()
  • remove_filter()
  • remove_all_filters()
  • has_filter()