Redirect to front page wordpress if not logged in

admin

Administrator
Staff member
I'm looking to redirect a user to a specific page if they are not logged in.
So blog.com/welcome

So they can either be viewing this page or wordpress login pages.
I was trying to modify this plugin
<a href="http://wordpress.org/plugins/redirect-to-login-if-not-logged-in/" rel="nofollow">http://wordpress.org/plugins/redirect-to-login-if-not-logged-in/</a>

Code:
add_action( 'wp', 'dmk_not_loggedin_redirect' );

function dmk_not_loggedin_redirect() {
    global $pagenow;

However I am ending up with redirect loops. And I could use some help to stop this.

Code:
if ( ! is_user_logged_in() &amp;&amp; $pagenow != 'wp-login.php' or 'http://www.blog.co.uk/front' )
    wp_redirect( 'http://www.blog.co.uk/front' , 302 ); exit; }