Bug Description
When using Spectra with Ultimate Member and a block theme, all single posts/pages return a 302 redirect to the homepage for non-logged-in users.
Root Cause
determine_template_post_type() calls get_block_templates() early during every page load. When a page-user block template exists, WordPress creates a WP_Query to look up the page with slug "user" (the UM profile page). Ultimate Member's filter_protected_posts() hook intercepts this query and calls exit(wp_redirect(homepage)), killing the entire request before the actual page renders.
Steps to Reproduce
- Install Spectra 2.19.20 and Ultimate Member 2.11.2
- Use a block theme (e.g., Spectra One)
- Customize the User page template in the Site Editor (creates a
page-user template)
- Visit any article as a logged-out user
- Result: 302 redirect to homepage instead of the article
Expected Behavior
Template resolution via get_block_templates() should not trigger third-party post filters that can terminate the request.
Suggested Fix
Temporarily suppress third-party the_posts filters during get_block_templates():
// In determine_template_post_type(), before calling get_block_templates():
add_filter('the_posts', function($posts, $query) {
if (!$query->is_main_query()) {
$query->set('suppress_filters', true);
}
return $posts;
}, 1, 2);
Environment
- Spectra: 2.19.20
- Ultimate Member: 2.11.2
- WordPress: 6.x with block theme
- PHP: 8.1
Full Analysis
Full root cause analysis, code flow diagram, diagnostic tools, and fix: https://github.com/kooyaniks/um-spectra-redirect-bug
Bug Description
When using Spectra with Ultimate Member and a block theme, all single posts/pages return a 302 redirect to the homepage for non-logged-in users.
Root Cause
determine_template_post_type()callsget_block_templates()early during every page load. When apage-userblock template exists, WordPress creates aWP_Queryto look up the page with slug "user" (the UM profile page). Ultimate Member'sfilter_protected_posts()hook intercepts this query and callsexit(wp_redirect(homepage)), killing the entire request before the actual page renders.Steps to Reproduce
page-usertemplate)Expected Behavior
Template resolution via
get_block_templates()should not trigger third-party post filters that can terminate the request.Suggested Fix
Temporarily suppress third-party
the_postsfilters duringget_block_templates():Environment
Full Analysis
Full root cause analysis, code flow diagram, diagnostic tools, and fix: https://github.com/kooyaniks/um-spectra-redirect-bug