Adding Redirect Code to Page Template
-
For a plugin (theme my login) I want to use a custom login page. It works fine, looks great.
The problem is that on the proper wp-login.php, I have this bit of code that works beautifully –
<? if(is_user_logged_in()){ $current_user = wp_get_current_user(); $user_name = $current_user->user_login; $redirect_loggedin = '/' . $user_name; wp_redirect($redirect_loggedin); } ?>
If a person is logged in and they view the login page, it auto-redirects them to ‘their’ page. Exactly what I want it to do.
The problem is this. I cannot use this code on the custom (internal) login page. It gives me a ‘cannot modify the header’ error no matter where I put it. I even made a custom header file and tried the code in there, but it just seems to break down. It should be that if they view the custom page, it auto-redirects them to ‘their’ page, same as the basic wp-login.php page that I have working.
Is there any way to do this? Suggestions? Thank you!
- The topic ‘Adding Redirect Code to Page Template’ is closed to new replies.