Tutorial: WordPress and ZenPhoto login integration

Tutorial: WordPress and ZenPhoto login integration

If you log into WordPress successfully, then the changes below will automatically log you into ZenPhoto...

Add the following to wp-login.php (wordpress base directory) at the very begining of the file:

`require_once("zenphoto/zen/functions-db.php");

require_once("zenphoto/zen/auth_zp.php");`

before this line:

`require( dirname(__FILE__) . '/wp-config.php' );`

then go to around line 195, which reads `do_action('wp_login', $user_login);` and replace with the following:

`do_action('wp_login', $user_login);

setcookie("zenphoto_auth", sha1(admin.password), time()+5184000, WEBPATH);

$_zp_loggedin = true;

wp_redirect($redirect_to);

exit();`

Obviously the set cookie function needs you to input your username and password for ZenPhoto (unless of course you keep them at admin and password respectively)

Comments

  • trisweb Administrator
    Edited for code clarity. Yes, that should work, but it's not an ideal solution since it requires you change the WP code... oh well. Good job, thanks.
  • Thanks, I was going to modify it but the edit link had already disappeared. If it was an extensive change to WordPress core files, I agree it would not be very practical or elegant, but since it is a trivial change it will do, at least for now. I can look into working it into a WP plugin though.
  • Yes, a WP plugin would be splendid!
  • Thanks amory, it works!
  • wouldn't this set this cookie to anyone who logs into your wordpress and thereby let them have full control of your gallery?

    if you replace admin.password with $user_name.$user_pass wordpress will pass on each person's username and password into the cookie and the admin link will only show up for the person who's information matches the user/pw set in config.php.
  • Correct, the cookie for ZenPhoto is then set per each user login. Therefore any of the website's administrators, regardless of user level, will be able to add photos.
  • Correct, the cookie for ZenPhoto is then set per each user login. Therefore any of the website's administrators, regardless of user level, will be able to add photos.
    I wouldn't think this would be a good idea as anyone who registers for your site can add, delete, wreak havok. But to each his own. At least with both ways posted people have a choice.
  • Amory, I'd also love to see this as a plugin.
  • I wouldn't think this would be a good idea as anyone who registers for your site can add, delete, wreak havok. But to each his own. At least with both ways posted people have a choice.
    The intention for my purpose was for EventPress, a concert/band/event management platform I'm working on of which will use multiple admin users. If the end user wanted to have a community of sorts on the website you could always add in an if/else for user level etc.. but for my purpose that seems redundent.
  • Any update on converting this to a plugin. I wouldn't use it unless it could be restricted to certain users, but would be a great addition.
  • I had to change the code when I implemented this to the following.

    do_action('wp_authenticate', array(&$user_login, &$user_pass));
    setcookie("zenphoto_auth", sha1(historian.plunger), time()+5184000, WEBPATH);
    $_zp_loggedin = true;

    could just be a WP2 thing.
  • hip Member
    I've just posted a different approach at
    http://www.zenphoto.org/support/topic.php?id=755#post-4165

    Hope it helps (a bit).
    Have a good day,
    hip
  • flick Member
    Unfortunately I can't seem to get the code to work with Zenphoto 1.0.8.2 and WP 2.1.3...
Sign In or Register to comment.