Ok, ok, I can see some of you cringing about this, but lets say I
wanted to include and bootstrap WordPress so that I can call some of
the WordPress functions. A typical example might be to print out a
list of posts on a page on another (locally hosted) site.
In my situation I had a Zend Framework application sat next to a
WordPress install. I managed to figure out how to share user details
across the systems, so that when a user logs into one they are logged
into both, but I had one small stumbling block.
When a user logged out of the ZF application I wanted it to also log
the user out of the WordPress application. I thought it might be a
good idea to do the following (which is detailed on the WP site[1])
and then use the WordPress functions to logout:
define('WP_USE_THEMES', false);
require('../wp-blog-header.php');
But what happened was that WordPress tried to look up an option from
the options table, but somehow lost the table prefix we had, which
meant that it couldn't see the tables. This meant it redirected the
user to the install page. So I tried to force the prefixes to be put
in place like this.
global $table_prefix;
$table_prefix = 'wp_';
define('WP_USE_THEMES', false);
require('../wp-blog-header.php');
This made the application work, but ended up causing an infinite loop
to occur as the system bounced back and forth between the
authentication states of WordPress and my application.
I may have just answered my own question here (I'll post this anyway),
but has anyone else done anything like this. Is there any way of
bootstrapping WordPress just enough to get access to the API
functions? I fixed the above problem in a different way, but I thought
that this should be possible.
Answers on a postcard I guess :)
Thanks!
Phil
[1]
http://codex.wordpress.org/User:Jalenack/Integrating_Wordpress_into_an_Existing_Site