I am writing a function to force a redirect when accessing a certain page.
I have done similar things using code like
if ( is_main_query() &&
( is_singular($restricted_post_types)||is_single() )
&& ! is_user_logged_in() ) {
wp_redirect(...)
}
But now I want to target a certain class of pages (profile related pages in the bbpress plugin bc Genesis is destroying them). I don’t know what I can use to identify this from an action in the template_redirect hook.
I think anything with the pattern '<baseurl>/forums/user'
would catch what I need
If you’re trying to catch the pattern ‘/forums/user’, you could use PHP’s stringpos function. Something like this should capture what you’re looking for:
Make sure if you have “enforce trailing slashes” set that you use “/forums/user/” as your matching pattern instead. This code isn’t tested but should work.