📄 原始资料 | 展开查看原始 JSON(bricks-form-action-form_action.json){ “name”: “bricks/form/action/{form_action}”, “kind”: “filter”, “url”: “https://academy.bricksbuilder.io/developer/hooks/filters/filter-bricks-form-action-form_action/”, “scraped_at”: “2026-08-29”, “hook_name”: “bricks/form/action/…
📄 原始资料 | 展开查看原始 JSON(bricks-form-action-form_action.json)
{
"name": "bricks/form/action/{form_action}",
"kind": "filter",
"url": "https://academy.bricksbuilder.io/developer/hooks/filters/filter-bricks-form-action-form_action/",
"scraped_at": "2026-08-29",
"hook_name": "bricks/form/action/{form_action}",
"description": {
"en": "The bricks/form/action/{form_action} filter is triggered when a custom action (one that is not reserved by Bricks) is selected in a form. It allows developers to define custom logic for handling such actions dynamically. Bricks provides several reserved actions out of the box, including: If the user’s selected action is not in this list, the bricks/form/action/{form_action} filter is triggered. Here’s how you can handle a custom action called slack-notification :",
"zh": "Bricks 1.4 引入了 bricks/indexer/source/run_query 钩子,允许你修改自定义索引器数据源的运行查询。"
},
"parameters": [
{
"name": "form",
"type": "\\Bricks\\Integrations\\Form\\Init",
"type_zh": null,
"description": {
"en": "The current form instance, providing access to settings and submitted fields.",
"zh": "当前表单实例,提供对设置和已提交字段的访问。"
}
}
],
"example_usage": "// Handle the Slack notification action\nadd_action(\n 'bricks/form/action/slack-notification',\n function ( $form ) {\n $settings = $form->get_settings();\n $fields = $form->get_fields();\n\n\n // Implement Slack notification logic\n }\n);"
}
前言
Bricks 1.4 引入了 bricks/indexer/source/run_query 钩子,允许你修改自定义索引器数据源的运行查询。
用法
将代码加入子主题的 functions.php:
// Handle the Slack notification action
add_action(
'bricks/form/action/slack-notification',
function ( $form ) {
$settings = $form->get_settings();
$fields = $form->get_fields();
// Implement Slack notification logic
}
);
参数
$form (\Bricks\Integrations\Form\Init):当前表单实例,提供对设置和已提交字段的访问。
示例代码
官方示例用法
// Handle the Slack notification action
add_action(
'bricks/form/action/slack-notification',
function ( $form ) {
$settings = $form->get_settings();
$fields = $form->get_fields();
// Implement Slack notification logic
}
);
根据条件短路返回原值
根据条件跳过或修改返回值:
add_filter( 'bricks/form/action/{form_action}', function( $value, $form ) {
if ( is_admin() ) { return $value; }
// TODO: custom logic here
return $value;
} );
补充说明
更多细节可参考 官方文档。