WordPress.org

Ready to get started?Download WordPress

Forums

Theme My Login
[resolved] Redirect away from login page if signed in (7 posts)

  1. jetlej
    Member
    Posted 2 years ago #

    Currently if users go to my login page, they see a blank page (because I disabled viewing of WordPress profiles. Is there a way to redirect logged in users away from the login page to the home page?

    http://wordpress.org/extend/plugins/theme-my-login/

  2. Jeff Farthing
    Member
    Plugin Author

    Posted 2 years ago #

    Activate and use the Custom Redirection module.

  3. jetlej
    Member
    Posted 2 years ago #

    That's no the point. If they for some reason navigate back to my /signin page, they see a blank screen because they are already logged in. The redirect module on redirectly after they login the first time.

  4. Jeff Farthing
    Member
    Plugin Author

    Posted 2 years ago #

    function tml_template_redirect() {
    	global $theme_my_login;
    
    	if ( $theme_my_login->is_login_page() ) {
    		if ( is_user_logged_in() && 'logout' != $theme_my_login->request_action ) {
    			$redirect_to = home_url();
    			wp_redirect( $redirect_to );
    			exit;
    		}
    	}
    }
    add_action( 'template_redirect', 'tml_template_redirect' );
  5. jetlej
    Member
    Posted 2 years ago #

    Awesome, works perfectly. Thank you!

  6. pantone
    Member
    Posted 2 years ago #

    Sorry to have to revive this thread, but I wanted to ask:

    Jeff - Where does one place that code you provided?

  7. Jeff Farthing
    Member
    Plugin Author

    Posted 2 years ago #

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic