php - Redirect causing a redirect loop -


i used following code in function.php file redirect users not logged-in 'my-account' page promoted sign or log in.

if (   !in_array($globals['pagenow'], array('wp-login.php', 'wp-register.php', '/my-account'))   && !is_admin()   && !is_user_logged_in() ) {   wp_redirect('/my-account', 301);   exit; } 

however code causes redirect loop on 'my-account' page , can't seem work out why. newish php, help!

edit: amended /my-account typo


Comments