Last active
April 6, 2017 15:07
-
-
Save amdrew/1119f025ad896c05e2f5 to your computer and use it in GitHub Desktop.
AffiliateWP - Custom logout redirect for Affiliates
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
<?php | |
/** | |
* AffiliateWP - Custom logout redirect for Affiliates | |
* By default, a user is sent to the wp-login.php?loggedout=true page | |
* Affiliates are logged out to the affiliate dashboard login screen | |
* Normal WP users are logged out and redirected to the site URL | |
*/ | |
function affwp_custom_logout_redirect( $logout_url, $redirect ) { | |
if ( function_exists( 'affwp_is_affiliate' ) && affwp_is_affiliate() ) { | |
$redirect = affiliate_wp()->login->get_login_url(); | |
} else { | |
$redirect = site_url(); | |
} | |
$args = array( 'action' => 'logout' ); | |
if ( ! empty( $redirect ) ) { | |
$args['redirect_to'] = urlencode( $redirect ); | |
} | |
return add_query_arg( $args, $logout_url ); | |
} | |
add_filter( 'logout_url', 'affwp_custom_logout_redirect', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
/** Or you could use something like this and paste into your functions.php preferably located in a child theme "/
add_action('wp_logout','auto_redirect_after_logout');
function auto_redirect_after_logout(){
wp_redirect( 'http://www.yoursite.com');
exit();
}