Created
March 20, 2015 01:21
-
-
Save amdrew/599f3a35495e38c4f681 to your computer and use it in GitHub Desktop.
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
/** | |
* AffiliateWP - login and redirect affiliates to affiliate area | |
* All other users are redirected to the site's homepage | |
* | |
* Works when user logs in via the page where the [affiliate_login] shortcode is used | |
* Works when affiliate logs in via wp-login.php page so they don't see the admin | |
*/ | |
function affwp_custom_login_redirect( $user_login, $user ) { | |
$user_id = $user->ID; | |
// Redirect for affiliates | |
if ( function_exists( 'affwp_is_affiliate' ) && affwp_is_affiliate( $user_id ) ) { | |
$redirect = affiliate_wp()->login->get_login_url(); // affiliate dashboard | |
wp_redirect( $redirect ); exit; | |
} | |
} | |
add_action( 'wp_login', 'affwp_custom_login_redirect', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment