Browser: Chrome 110
OS: macOS / Windows / Linux / etc.
URL: Link to a page that illustrates this issue
Video: Short screen recording that illustrates this issue (free tool: jam.dev)
Since updating to Bricks 2.4.4, AJAX popups (“Fetch content via AJAX”) no longer load for logged-out visitors when the popup context is a post from a custom post type that is not publicly queryable. It returns:
{"code":"bricks_popup_context_not_available","message":"Popup data not found","data":{"status":403}}
When logged in as admin everything works.
We have the issue with a very common pattern using a CPT for team members (or testimonials, FAQs, locations…) registered with publicly_queryable => false, because these do not need their own URLs. Query loop on a regular page renders cards. Click on a card opens an AJAX popup with popupContextType: post and the loop item ID as context
Steps to reproduce:
- Register a CPT with public => false or publicly_queryable => false
- Create a popup template with “Fetch content via AJAX” enabled and some dynamic data (e.g. {post_title})
- On a page, loop over the CPT and add a click interaction that opens the popup
- Visit the page logged out and click a card
“403 bricks_popup_context_not_available, empty popup”
I tested the same request with different context IDs while logged out: regular posts, pages and public CPTs return 200, non-public CPTs return 403.
Setting the CPT to publicly_queryable => true fixes the popup, but creates single URLs that need redirects and SEO exclusions. Not ideal.
Workaround so far:
add filter for is_post_type_viewable(). Set the post type viewable for this special case (Two Steps: first mark that there is a popup request in ajax, then allow the post type if the mark is set)
add_filter( 'rest_request_before_callbacks', function ( $response, $handler, $request ) {
if ( $request->get_route() === '/bricks/v1/load_popup_content' ) {
$GLOBALS['bricks_popup_ajax_request'] = true;
}
return $response;
}, 10, 3 );
add_filter( 'is_post_type_viewable', function ( $is_viewable, $post_type ) {
if ( $is_viewable ) {
return true;
}
$allowed = [ 'mitarbeiter' ]; // This was our case, replace it with your CPTs
if ( ! empty( $GLOBALS['bricks_popup_ajax_request'] ) && in_array( $post_type->name, $allowed, true ) ) {
return true;
}
return false;
}, 10, 2 );
Tested on 2.4.4, popups work again for logged-out users.
It would be nice to add an official way to allow specific post types as popup context, for example a filter or even a setting.
Thank you
Michael