I'm looking already for over 3 hours now, and have found many possible solutions, but none of them works!
The (simple) situation:
- I have a fresh install of WordPress 2.7.1 installation on http://www.mysite.com/blog/
- On a page outside WP http://www.mysite.com/test/test.php I try to display the user that is currently logged in, etc.
What IS working:
require_once('../blog/wp-blog-header.php');
and:
$posts = get_posts('numberposts=10&order=ASC&orderby=post_title');
foreach ($posts as $post) : start_wp(); ?>
<?php the_date(); echo ""; ?>
<?php the_title(); ?>
<?php the_excerpt(); ?>
<?php
endforeach;
What IS NOT working:
(nothing is displayed)
global $current_user;
get_currentuserinfo();
echo $current_user->user_login;
Also NOT working:
(displays 'Welcome, visitor!' while I am logged in)
if (is_user_logged_in()){
echo "Welcome, registered user!";
} else {
echo "Welcome, visitor!";
};
btw I have no active plugins and just a couple of posts and 2 users (author/subscriber) for testing purposes.