jimboobrien
9/20/2017 - 11:37 PM

Login Redirect

Login Redirect

/**
* Redirects users away from login page if they're already logged in
* or Redirects to /store/ if they log out.
*
* @since 0.4.0
*
* @return void
*/
function login_out_page_redirect() {
	if ( is_user_logged_in() && 'login' == $this->_current_view ) {
		wp_redirect( it_exchange_get_page_url( 'account' ) );
		die();
	} else if ( is_user_logged_in() && 'logout' == $this->_current_view ) {
		$default = 'disabled' == it_exchange_get_page_type( 'login' ) ? get_home_url() : str_replace( '&', '&', wp_logout_url( it_exchange_get_page_url( 'login', false, true ) ) );
		$url = apply_filters( 'it_exchange_redirect_on_logout', $default );
		wp_redirect( $url );
		die();
	} else if ( ! is_user_logged_in() && 'logout' == $this->_current_view ) {
		wp_redirect( it_exchange_get_page_url( 'login' ) );
		die();
	}
}