Support » Plugins and Hacks » WP login on page outside WP

  • I have a page outside WordPress that displays some stuff from WP.

    I would like to restrict access to logged in users. Ideally I would like to return a 404 to anyone else. Is this possible?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Yep. Just after where wp-blog-header.php is included (you are doing this at the start of the document, right?), add a bit of PHP to return a 404 to non-logged-in visitors:

    <?php
    include('./wp-blog-header.php');

    global $user_login;
    if(!$user_login) {
    header("HTTP/1.0 404 Not Found");
    exit;
    }
    ?>

    Thanks Kafkaesqui, done in seconds and working fine.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘WP login on page outside WP’ is closed to new replies.