• Resolved strictlystereo

    (@strictlystereo)


    Can anyone get me started with implementing custom PHP visibility conditions? Looking at the documentation, it seems like I should be able to use the block_visibility_is_block_visible filter for this…

    https://blockvisibilitywp.com/knowledge-base/filter-slot-reference/#h-php-filters

    …but I just cannot seem to get it to work. I would ideally like to use this feature to show or hide a block displaying warranty information, based on the brand of the current product. I use full site editing and this particular block would be placed on my Woocommerce single product template, rather than on a page or in the product content itself.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Author Nick Diego

    (@ndiego)

    Hi @strictlystereo,

    So while that filter is an option, you will probably want to use block_visibility_control_set_is_block_visible. This is a lower level filter designed for individual visibility conditions. That said, this filter is designed to work in conjunction with a custom block attribute that you have added to the block based on your custom visibility condition. You can refer to this demo plugin for a complete example of how to build something like this.

    If you just want to conditionally render a block based on some condition, without integrating into the Block Visibility editor user interface, there are easier methods. I would recommend just using the core render_block filter. This is actually what Block Visibility uses under the hood.

    Hope that helps.

    Best,
    Nick

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.