I created the Block Context plugin to change the visibility of WordPress blocks based on various rules and conditions. It uses the render_block
filter to hide a block based on the rules selected in the block settings:

Visibility Rules
What are the conditions and rules that would be actually useful to you? Please leave a comment below or send me a message on Twitter with your suggestions.
Here is what I have come up with so far:
- Users and user roles — targer logged-in or logged-out users, specific user roles and capabilities.
- Time and date period — select a date range when the block is visible.
- Device type — mobile, desktop, tablet, etc. This should be done in JS/CSS to ensure it works with any kind of caching.
- Referrals — show blocks to users coming from search engines, social networks, specific URLs, etc.
What else? Can’t wait to hear your suggestions!