Hi hybridixstudio,
Compare the original code:
add_action( 'parse_request', 'dmk_redirect_to_login_if_not_logged_in', 1 );
/**
* Redirects a user to the login page if not logged in.
*
* @author Daan Kortenbach
*/
function dmk_redirect_to_login_if_not_logged_in() {
is_user_logged_in() || auth_redirect();
}
With this adjusted code with added conditionals:
add_action( 'parse_request', 'dmk_redirect_to_login_if_not_logged_in', 1 );
/**
* Redirects a user to the login page if not logged in.
* Added is_page() conditional
*
* @author Daan Kortenbach
*/
function dmk_redirect_to_login_if_not_logged_in() {
// If on this page, do not redirect
if ( is_page( 'change-me-to-page-slug' ) )
return;
// If on this post, do not redirect
if ( is_single( 'change-me-to-post-slug' ) )
return;
// Conditional(s) above were false, redirect
is_user_logged_in() || auth_redirect();
}
You can fork the plugin at Github (https://github.com/daankortenbach/redirect-to-login-if-not-logged-in) and change the code to your liking.
Also, here is a gist with the changed code: https://gist.github.com/daankortenbach/9428467