-
-
Save jimboobrien/2a0aacd48be04031fcf8f72de098fff3 to your computer and use it in GitHub Desktop.
Login Redirect
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment