login_redirect not working with s2 Members WordPress Plugin

Recently I came across an issue that I wasn’t able to use login_redirect filter for some reason. I dig deep down to find out the problem, so I print_red the wp_filter variable at wp-login.php file and came to know that the login_redirect hook was being tinkered by s2_member plugin. For me it came as a shocker because such reputated plugin was using such hard core technique and preventing its user to have more flexibility than what they were offering. So I removed the function which s2member plugin was using to deavtivating login_redirect hook and it turned out to work really well. Here is the code which I used to fix the problem:

function fix_login_redirect() {

remove_filter( “init”, ‘c_ws_plugin__s2member_login_redirects_r::remove_login_redirect_filters’, 11 );

}
add_action( ‘init’, ‘fix_login_redirect’, 1, 3 );

And now if you use the login_redirect filter to redirect user after login, you will have it working well:

function cc_login_redirect( $redirect_to, $request, $user ) {

	return "http://google.com";	

}	
add_filter( 'login_redirect', 'cc_login_redirect', 1, 12 );

Leave A Comment