2 deleted 21 characters in body
source | link

I have integrated custom login form as mentioned here and embed this custom login form to a WordPress page, via shortcode [dm_login_form].

After that I have integrated access control plugin here which allows me to redirect user to login page if not logged in.

I need to redirect user to my custom login page whenever a blog post/page is accessed by a non-authenticated user. It goes into redirect loop if I provide my custom login page URL.

For admin authentication I am using default wp-login.php URL while other users login using custom login page URL.

Code in functions.php for redirection

add_action('template_redirect', 'redirect_user');

function redirect_user(){
    global $current_user;
    if (!is_page('login') && !is_user_logged_in()){
        $return_url = site_url().'/login';
        wp_redirect($return_url);
        exit();
    }
}

I just need to redirect user to my login page URL if hes not logged in and try to access any page/post. How can I prevent this redirect loop ?

Thanks.

I have integrated custom login form as mentioned here and embed this custom login form to a WordPress page, via shortcode [dm_login_form].

After that I have integrated access control plugin here which allows me to redirect user to login page if not logged in.

I need to redirect user to my custom login page whenever a blog post/page is accessed by a non-authenticated user. It goes into redirect loop if I provide my custom login page URL.

For admin authentication I am using default wp-login.php URL while other users login using custom login page URL.

Code in functions.php for redirection

add_action('template_redirect', 'redirect_user');

function redirect_user(){
    global $current_user;
    if (!is_page('login') && !is_user_logged_in()){
        $return_url = site_url().'/login';
        wp_redirect($return_url);
        exit();
    }
}

How can I prevent this redirect loop ?

Thanks.

I have integrated custom login form as mentioned here and embed this custom login form to a WordPress page, via shortcode [dm_login_form].

After that I have integrated access control plugin here which allows me to redirect user to login page if not logged in.

I need to redirect user to my custom login page whenever a blog post/page is accessed by a non-authenticated user. It goes into redirect loop if I provide my custom login page URL.

For admin authentication I am using default wp-login.php URL while other users login using custom login page URL.

Code in functions.php for redirection

add_action('template_redirect', 'redirect_user');

function redirect_user(){
    global $current_user;
    if (!is_user_logged_in()){
        $return_url = site_url().'/login';
        wp_redirect($return_url);
        exit();
    }
}

I just need to redirect user to my login page URL if hes not logged in and try to access any page/post. How can I prevent this redirect loop ?

Thanks.

1
source | link

Custom Login Form - Redirect user to login page if not logged in

I have integrated custom login form as mentioned here and embed this custom login form to a WordPress page, via shortcode [dm_login_form].

After that I have integrated access control plugin here which allows me to redirect user to login page if not logged in.

I need to redirect user to my custom login page whenever a blog post/page is accessed by a non-authenticated user. It goes into redirect loop if I provide my custom login page URL.

For admin authentication I am using default wp-login.php URL while other users login using custom login page URL.

Code in functions.php for redirection

add_action('template_redirect', 'redirect_user');

function redirect_user(){
    global $current_user;
    if (!is_page('login') && !is_user_logged_in()){
        $return_url = site_url().'/login';
        wp_redirect($return_url);
        exit();
    }
}

How can I prevent this redirect loop ?

Thanks.