Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question
    
What do you mean by "Genesis is destroying them"? Genesis is removing those pages? –  Dan Ștefancu Sep 24 '13 at 22:32
    
not rly sure why but it's removing most of the markup. twentytwelve theme: imgur.com/HJKeRg3 vs base genesis: imgur.com/SMcmKvS –  Damon Sep 25 '13 at 13:03

1 Answer 1

up vote 1 down vote accepted

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:

$url_pattern = "/forums/user";
$requested_uri = $_SERVER["REQUEST_URI"];

if(strpos($requested_uri, $url_pattern) == 0){
    //Your code goes here
}

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.