404_template hook fires wrongly
-
Hi,
I’m the author of the 404page plugin, the most used plugin to create custom 404 error pages. My plugin uses the 404_template filter. Due to a user’s request I found out that this hook fires incorrectly in a particular case caused by bbPress. Of course I can bypass the problem but I wonder if you’d like to fix it because it is a bbPress issue.
On showing the profile page of a single member bbPress changes the main query to get the topics created by that member. This causes $wp_query->is_404 is set to true because no posts are found. This does not affect bbPress because $wp_query->bbp_is_single_user is set to true which causes the bbPress template loader to load the suitable template file.
But at the same time the WP core template loader fires the 404_template filter hook. This is fallacious because there is no 404 error.
I could fix that in my plugin by checking $wp_query->bbp_is_single_user but this would only bypass the problem. It is definitely wrong the 404_template hook fires in that case.
So I think it would be a good idea to correct this in bbPress. You’d only have to set $wp_query->is_404 to false after the main query was executed in case $wp_query->bbp_is_single_user is true.
In my opinion the bbp_template_redirect hook would be the right place to do that. Adding one more small function to this hook solves the issue.
I’m curious about your response.
Regards,
Peter
- You must be logged in to reply to this topic.