Black Friday: 79% off every plugin Shop the sale →

Hooks & Filters

Filters#

FilterArgumentsPurpose
section_blocks_pro_block_is_visiblebool $visible, array $attrs, array $blockFinal say on whether a Section Blocks block with conditions is shown on this request. Runs after the login, role and date checks. Return false to hide, true to show.
section_blocks_pro_storeengine_product_idint $product_idOverride the store product ID used for licensing. For custom builds only.
section_blocks_pro_storeengine_store_urlstring $urlOverride the store URL used for licensing and updates. For custom builds only.
section_blocks_pro_storeengine_allow_localbool $allowWhether license activation is allowed on local hosts. Default true.
section_blocks_pro_store_dashboard_urlstring $urlURL of the “Manage License” link on the license screen.

There are no actions and no shortcodes.

section_blocks_pro_block_is_visible only runs for blocks that have at least one condition set, and only while Pro is active with a valid license. It does not run for the device rule, which is CSS.

Example: hide a block from users without an active membership#

Suppose a membership plugin stores access in user meta rather than in roles. Combine the block’s roles check with your own:

add_filter( 'section_blocks_pro_block_is_visible', function ( $visible, $attrs, $block ) {
	// Only touch blocks the editor limited to logged-in users.
	if ( ! $visible || ( $attrs['sbpVisibility'] ?? '' ) !== 'logged-in' ) {
		return $visible;
	}

	return (bool) get_user_meta( get_current_user_id(), 'membership_active', true );
}, 10, 3 );

Example: always show conditional blocks to administrators#

Useful on staging, so editors can review scheduled content on the public site:

add_filter( 'section_blocks_pro_block_is_visible', function ( $visible ) {
	return $visible || current_user_can( 'manage_options' );
} );

Example: hide a specific block type on a specific page#

add_filter( 'section_blocks_pro_block_is_visible', function ( $visible, $attrs, $block ) {
	if ( 'section-blocks/promo-banner' === ( $block['blockName'] ?? '' ) && is_page( 'checkout' ) ) {
		return false;
	}
	return $visible;
}, 10, 3 );

Confirm the exact block names in the free plugin (they are listed by section_blocks_get_block_names() when the free plugin is active) before relying on a hard-coded name.

Block attributes#

Pro registers these attributes on every Section Blocks block, on the server (register_block_type_args) and in the editor.

AttributeTypeValues
sbpVisibilitystring'' (everyone), logged-in, logged-out
sbpRolesstring[]Role slugs, used only with logged-in
sbpDevicestring'' (all), mobile, desktop
sbpDateStartstringYYYY-MM-DDTHH:MM as saved by the editor’s date-time field, interpreted in the site time zone
sbpDateEndstringSame format

CSS classes#

ClassAdded when
sbp-only-mobileDevice is “Mobile only”; hidden at 768px and up
sbp-only-desktopDevice is “Desktop and tablet only”; hidden below 768px

To change the breakpoint, dequeue the inline style for the section-blocks-pro-conditional-display handle and add your own media queries for these classes.

Helper functions and constants#

NamePurpose
section_blocks_pro_features_enabled()true when the free plugin is compatible and the license is valid. Use it to guard your own Pro-dependent code.
Section_Blocks_Pro_License::is_active()License validity from local state (no remote call).
SECTION_BLOCKS_PRO_VERSIONPlugin version string.
SECTION_BLOCKS_PRO_MIN_FREE_VERSIONLowest free Section Blocks version Pro runs with (1.3.0).
Was this article helpful?