I’m building a small web app to sit within an existing Wordpress membership site.
At the moment, all of the content is protected using Digital Access Pass, which handles user authentication and content protection.
I’m thinking of using Yii for this, and installing it into a subdirectory of the Wordpress site.
My plan is to have this layout:
www.site.com (wordpress blog)
www.site.com/members (content protected with the Digital Access Pass membership solution, set up in Wordpress)
www.site.com/members/app (yii folder - protected by DAP, but not set up in Wordpress)
I don’t want to do a full integration, as I’m using a lot of Ajax and that doesn’t look like it will work too well from the examples I’ve seen.
What I’d like is to use DAP to protect the pages and handle authentication, and also to pass the logged- in userid to Yii so I can use as a key to store user preferences, user data, etc.
The way DAP works is that you just insert the following code into any page you want to protect, and then you can access a User object that contains the info I need.
<?php
include_once "../dap/dap-config.php";
$user = null;
if( !Dap_Session::isLoggedIn() ) {
//send viewer to login page
header("Location:".SITE_URL_DAP.Dap_Config::get("LOGIN_URL"));
exit;
}
else if( Dap_Session::isLoggedIn() ) {
//get userid
$session = Dap_Session::getSession();
$user = $session->getUser();
$user = Dap_User::loadUserById($user->getId()); //reload User object
if(!isset($user)) {
//send viewer to login page
header("Location:".SITE_URL_DAP.Dap_Config::get("LOGIN_URL"));
exit;
} else {
$userProducts = Dap_UsersProducts::loadProducts($user->getId());
}
}
?>
How do I go about implementing this in Yii?