Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am using wordpress and I normally use:

if (!is_user_logged_in()){
   //something here
}

to detect if the wordpress user is logged in or now.

My problem is that I need to detect if the user is logged in to wordpress from a non-wordpress page.

My page is in the same directory as the other wordpress pages but is not page of wordpress.

How can I detect this from my page?

share|improve this question
add comment

2 Answers

Simply place

define( 'WP_USE_THEMES', false );
include 'wp-load.php';

on to of your template files (before everything else). This loads the whole WP core.

share|improve this answer
add comment

this is untested by me, but please have a look at this article: Integrating Wordpress into an Existing Site

In essence I believe that if you use:

<?php require('/the/path/to/your/wp-blog-header.php');?>

..at the top of you (php) page you should be able to take advantage of the is_user_logged_in() function.

share|improve this answer
    
Hi, I'm new to Stack Exchange in general, so is there a way I can see why a post is voted down? Presumably this didnt work, or did I not include enough info? –  Mere Development Feb 3 '12 at 17:21
    
Normally the downvoter should leave a reply, but they're not forced to. –  kaiser Feb 3 '12 at 23:48
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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