If you add the wp_redirect part to an action callback, then it should work. So in your functions.php or somewhere you will need:
add_action( 'pre_posts, 'am_login_redirect' );
function am_login_redirect() {
if( is_user_logged_in() ){
wp_redirect( home_url() );
exit;
}
}
After going through many of them, I found that “”pre_posts” seems to work the most consistently for me on different environments.
add_action( 'pre_posts', 'restrictPage_blah', 100 );
What about if you are using domain mapping? Which one will end up being easier to manage in the long run?