WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

how would one go about redirect certain pages if the user viewing them is logged into the WordPress CMS? For example, we have 2 registration pages that when logged in should direct to some other page / category archive.

Thanks.

share|improve this question
up vote 1 down vote accepted

$location = The absolute URI to which the user will be redirected. No default. $status = The status code to use. For example, 301, 302, etc. The default is 302. You can use template tags for the $location parameter, for example:

<?php // redirect to the home page
wp_redirect(home_url()); exit; ?>

<?php wp_redirect('http://example.com/', 301); exit; ?>

If user is logged in

<?php if (is_user_logged_in() ) {
wp_redirect ( home_url("/pagename") );
exit;
}
?>
share|improve this answer

Your Answer

 
discard

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