Description
This filter hook allows developers to modify whether a block should be rendered based on ACF field visibility rules. This hook is triggered during the block rendering process when the block has ACF visibility settings enabled.
Parameters
apply_filters( 'afb/should_render_block', $should_render, $rules, $block );
$should_render
(bool)
Whether the block should be rendered based on evaluated visibility rules
$rules
(array)
Array of visibility rule groups and their evaluation results
$block
(array)
The complete block data including attributes and content
Example
add_filter( 'afb/should_render_block', function( $should_render, $rules, $block ) {
return true;
}, 10, 3 );
add_filter( 'afb/should_render_block', function( $should_render, $rules, $block ) {
if ( ! current_user_can( 'manage_options' ) ) {
return false;
}
return $should_render;
}, 10, 3 );Code language: PHP (php)