Last active
January 12, 2017 20:44
-
-
Save wpbullet/aada5788b68a2e620f445007a4dff769 to your computer and use it in GitHub Desktop.
This file contains 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 | |
/* | |
Plugin Name: Subscriber Redirect Fix | |
Plugin URI: | |
Description: | |
Version: | |
Author: | |
Author URI: | |
License: | |
License URI: | |
*/ | |
/** | |
* Redirect user after successful login. | |
* | |
* @param string $redirect_to URL to redirect to. | |
* @param string $request URL the user is coming from. | |
* @param object $user Logged user's data. | |
* @return string | |
*/ | |
function my_login_redirect( $redirect_to, $request, $user ) { | |
if ( isset( $user->roles ) && is_array( $user->roles ) ) { | |
if ( in_array( 'subscriber', $user->roles ) ) { | |
return home_url(); | |
} | |
} | |
return $redirect_to; | |
} | |
add_filter( 'login_redirect', 'my_login_redirect', 9999999, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment