Title: Conditional redirect
Last modified: August 22, 2016

---

# Conditional redirect

 *  [deshmukh](https://wordpress.org/support/users/deshmukh/)
 * (@deshmukh)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/conditional-redirect-3/)
 * I have redirected example.com to example.com/wp-login.php.
 * So, a user goes directly to wp-login.php and after logging in, is taken to an
   appropriate page using Peter’s login redirct plugin.
 * However, if a logged in user tries going to example.com, he is still taken to
   example.com/wp-login.php asking for password.
 * I want the redirection to be conditional. So, a user is taken to wp-login.php
   ONLY IF he is not already logged in.
 * How can this be done?

Viewing 1 replies (of 1 total)

 *  [nilay89](https://wordpress.org/support/users/nilay89/)
 * (@nilay89)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/conditional-redirect-3/#post-5691436)
 * Hi
 * Please try this function for user logged in or not
 * “is_user_logged_in()”
 * **if (is_user_logged_in())
    { echo “user logged in”; } else { echo “user not 
   logged in”; }
 * Hope help this

Viewing 1 replies (of 1 total)

The topic ‘Conditional redirect’ is closed to new replies.

## Tags

 * [redirect](https://wordpress.org/support/topic-tag/redirect/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [nilay89](https://wordpress.org/support/users/nilay89/)
 * Last activity: [11 years, 4 months ago](https://wordpress.org/support/topic/conditional-redirect-3/#post-5691436)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
