My use case: I am creating a new website and moving off of some old technologies, and am looking to use WP Fusion and Block Visibility going forward. We require our site to have “bypass” links which would allow a visitor using a specific link to view a page even if certain content would normally require a user to be logged in and have a specific membership level.
When using the block_visibility_is_block_visible filter to control access, however, it is ignoring the filter when a user is not logged in because it hard-codes the user as not having access after the filter is applied.
Step-by-step reproduction instructions
- Create a block, set a user role (logged in, or subscriber, or any valid option so a normal link will appear if they fit that user role), save the page.
- Visit the page; if you are logged in, it appears. If you are not, it won’t.
- Add the following code listed below to your functions.php file.
- Visit the page; if you are logged in, it appears. If you are not, it still won’t.
add_filter( 'block_visibility_is_block_visible', 'private_tags_bypass_bv_check', 15,3 );
function private_tags_bypass_bv_check($is_visible, $settings, $controls) { return true; }(In my actual use case, I have a plugin which decides if the block should be visible or not depending on other criteria, but the above reproduction steps are an easy way to spot the bug.)
The page I need help with: [log in to see the link]
