Hi,
I unluckily tried to apply the methos explained at [b]Tutorial: WordPress and ZenPhoto login integration'[/b] (http://www.zenphoto.org/support/topic.php?id=40) to integrate WP and Zen under one unique user+pass. So I did my own from the opposite approach: I tweaked (yes, sorry) the Zen auth_[b]zp.php file[/b].
In case anyone is interested I copy the code below (without much explanation. Investigate a bit, please) which works for me. I don't allow visitors to register at my WP website so I don't need to identify what role the logged user is. You don't need either the Zen login form anymore for the user login control is taken by WP and the admin (for both WP and Zen) has to go through the WP login page.
The code for [b]zen/zp.php file[/b] (take it as a working drought, please):
/
if (isset($_COOKIE['zenphoto_auth'])) {
$saved_auth = $_COOKIE['zenphoto_auth'];
$check_auth = md5(zp_conf("adminuser").zp_conf("adminpass"));
if ($saved_auth == $check_auth) {
/
if (file_exists('../../wp-config.php')) {require_once('../../wp-config.php');} //hip
else if (file_exists('../wp-config.php')) {require_once('../wp-config.php');}
else {die('I\'m such a nerd that couldn\'t find it!');}
global $user_ID;
if("" == $user_ID) { echo ("you are logged out"); } //logged out -> do whatever you wish. Usually a redirect.
else { $_zp_loggedin = true; } //logged in -> let it go!
/
} else {
// Clear the cookie
setcookie("zenphoto_auth", "", time()-368000, $cookiepath);
}
} else {
// Handle the login form.
if (isset($_POST['login']) && isset($_POST['user']) && isset($_POST['pass'])) {
$user = $_POST['user'];
$pass = $_POST['pass'];
$redirect = $_POST['redirect'];
if ($user == zp_conf("adminuser") && $pass == zp_conf("adminpass")) {
// Correct auth info. Set the cookie.
setcookie("zenphoto_auth", md5($user.$pass), time()+5184000, $cookiepath);
header("Location: " . "http://" . $_SERVER['HTTP_HOST'] . WEBPATH . $redirect);
$_zp_loggedin = true;
} else {
// Clear the cookie, just in case
setcookie("zenphoto_auth", "", time()-368000, $cookiepath);
$error = true;
}
}
}
/
Have a good day,
hip
hip, do I replace the contents or do I add this to the auth_zp.php file?
Hi Hip, why are you saying that it's not recommended? Does it have to change databases a lot?