I want to use Zend_Auth::getInstance()->hasIdentity() in Wordpress frontend index.php, how to do it
Actually I've installed Zend and created an application under http://example.com/
I installed wordpress under http://example.com/blog/
Zend and Wordpress are using different Databases.
RewriteRule ^blog - [NC,L]
RewriteRule ^.*$ public/index [NC,L]
Above code in .htaccess has been used to allow access to /blog/
Now I want to use Zend_Auth::getInstance()->hasIdentity() in Wordpress frontend ind开发者_C百科ex.php, so if someone use Zend logged in, they are allowed to see this blog , if not, they will be re-direct to another page.
Can anyone help me with this ?
in wordpress index.php do
require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
if(Zend_Auth::getInstance()->hasIdentity())
{
//do what you want here
}
since its wordpress it wont have zend framework methods. if you are re directing to wordprress for like a blog posting thing or something what you can do is var dump or print_r the session array and find the variable zend framework set to keep track of the session and use it however you like. if you dont have tem running side by side you can just use wordpress built in features to manage your log ins.
精彩评论