I have a custom page template that looks like this:

<?php if( is_user_logged_in() ): ?>
<?php get_header(); ?>
 <?php while ( have_posts() ) : the_post(); ?>
   <?php get_template_part( 'content', 'page' ); ?>
   <?php thinkup_input_nav( 'nav-below' ); ?>
   <?php thinkup_input_allowcomments(); ?>
   <?php endwhile; wp_reset_query(); ?>
<?php get_footer(); ?>
<?php else:
  wp_die('Sorry, you must first <a href="/wp-login.php">log in</a> to view this page. You can <a href="/wp-login.php?action=register">register free here</a>.');
endif; ?>

Now, when I browse to the page that uses this page template, I'm asked to login. After the login, I'm redirected to the Wordpress admin panel. Browsing manually to the page only shows the same login again.

  • How can I ensure that is_user_logged_in() detects that I'm logged in; and
  • That I'm redirected to the page itself.


  • Are you using SSL at all? Aug 29, 2015 at 19:40
  • Yes, I have SSL activated for the admin section, as follows in the wp-config.php: define('FORCE_SSL_ADMIN', true); Aug 29, 2015 at 20:32
  • The following thread will explain why if you login via SSL, then any page where you check if user is logged in will also need to be secure wordpress.org/support/topic/… Aug 31, 2015 at 7:23

2 Answers 2


By removing the ADMIN SSL login in wp-config.php, I solved this.

So, remove this:

define('FORCE_SSL_ADMIN', true);

Read more about this feature here


Try logging in with an account that's NOT an admin account. I think that's just a quirk of an admin account...it assumes you want to go to the control panel.

  • Nope, that is not it. I tried logging in with another ordinary user. I'm still redirected to the Dashboard (for that user) after logging in. Also, trying to navigate to the page after leads to the same login form again. Aug 30, 2015 at 8:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.