Exchange FAQs: How Do I Change Where the User Redirects to After Logging Out

From IThemes Codex
Revision as of 06:20, June 12, 2014 by Glennansley (Talk | contribs)
Jump to: navigation, search

Modify Default Redirects Add-on

Use the "Modify Default Redrects" add-on to accomplish this without editing core Exchange files.

Editing Core Exchange Code (not recommended)

By default in Exchange, when your customer logs out, they will be redirected to the Log In page. You can change this however.

To do this, go into /lib/pages/ and you'll find the class.pages.php file. On line 181 (this may vary as Exchange is updated), you'll find the start of the function that controls where the user is taken after logging out.

/**
* 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();
	}
}

You'll want to change the value of $default. So, if you want your customer taken to the store page after logging out, that line would look like this:

$default = 'disabled' == it_exchange_get_page_type( 'store' ) ? get_home_url() : str_replace( '&', '&', wp_logout_url( it_exchange_get_page_url( 'store', false, true ) ) );


See Also

Quick Links

Resources

  • Tutorials - Short video tutorials to help you become an Exchange expert.

Support

Report & Request


← Back to Exchange Codex Home

Personal tools
Namespaces
Variants
Actions
iThemes Codex
Codex Navigation
Toolbox