ZenphotoCMS Forum
Login-Only Page? - Printable Version

+- ZenphotoCMS Forum (https://forum.zenphoto.org)
+-- Forum: Support (https://forum.zenphoto.org/forum-1.html)
+--- Forum: General support (https://forum.zenphoto.org/forum-4.html)
+--- Thread: Login-Only Page? (/thread-6254.html)



Login-Only Page? - statvoid - 2009-12-09

Hello,

I'm creating a semi-private website that is exclusively for photographs that I've taken for clients. Basically I create an album which only that client can see when they log in. I've gotten that far.

Now what I'm trying to figure out is how can I make it so that, unless you are currently logged in, the only thing you have access to is a page with a log in form? I have Zenpages installed and plan to use the user_login-out plugin to create the form. What I have created so far is a page in Zenpages that gives a little bit of info about the site and contains the login form. I have successfully created that page, but how can I set it up so- unless you are logged in- that is the only page you have access to?

Could it be done with another plugin? Can it be done with a script? This is basically the last big hurdle I have keeping me from getting the site completely where I need it to be. I'm not great at PHP scripting so any assistance would be great. Thanks!

Btw, I'm also using the ZPfocus theme if that makes any difference.




Login-Only Page? - acrylian - 2009-12-09

You will have to modify the Zenpage related theme page files with a login check as Zenpage pages and articles do not know about rights to specific users (except for editing on the backend you can lock pages/articles).

if(!($_zp_loggedin) { .... } would probably do the trick.

You can also specify the rights further like this:
if(!($_zp_loggedin & (ADMIN_RIGHTS | ZENPAGE_RIGHTS))) {...}




Login-Only Page? - statvoid - 2009-12-09

Thanks for the quick response!

Where would I put that in the theme file? At the very top and using the closing tag at the very bottom? Will this also keep logged out users from the main gallery page as well? And lastly will it send them to the login page upon loading?

What I'm going for is if you're not a logged-in user, whether you try [website]/gallery or [website]/page, it should load a log in form or redirect you to my custom login page (created by Zenpages).




Login-Only Page? - acrylian - 2009-12-09

It would protect or not display the content enclosed. You would have to put that around the content of all theme pages that should be protected.

A another quick idea. Create a static custom page (not a Zenpage page!) called for example loginpage.php with your form and then place this at the very top of every theme page to be protected:

if(!$_zp_loggedin) { include("loginpage.php"); break; }
This will load always the custom page unless you are loggedin. Probably this would make a nice plugin, too... I'll put that on my long list for sometime later.




Login-Only Page? - statvoid - 2009-12-09

Excellent, that is precisely what I was looking for! Thank you so much!




Login-Only Page? - statvoid - 2009-12-09

Sorry! While it works great, I am now getting this at the bottom of the pages...

Fatal error: Cannot break/continue 1 level in /[home_dir]/themes/zpfocus/index.php on line 4

How can I fix this?




Login-Only Page? - acrylian - 2009-12-09

Sorry, try exit instead of break.




Login-Only Page? - sbillard - 2009-12-09

A better approach would be to create a login script for that theme. See how the standard themes have done this. Of course you make this script/form specific to how you want your site to work.




Login-Only Page? - acrylian - 2009-12-09

That is what he actually does. In standard themes there is the password.php page. But that does not protect the full gallery if someone is not logged in. And that is what he wants to do. Unless I might be missing a detail myself.




Login-Only Page? - statvoid - 2009-12-09

exit helped! Thanks!

Basically I just took the code and placed it into the theme's index.php. While the pages aren't protected at the moment, I don't need them to be just yet (this was a last minute decision).

Although I would suggest maybe a way for Zenpages to be expanded slightly to hide pages from non-members (or visible to only people who are allowed to; usergroups). Almost like being not-published, except that only logged-in people can see it. Kind of as if you're not logged in you can see, say, 4 of 10 pages. The point being maybe those are informational. The remaining 6 require you to be a member because they include special content.

I guess it would be like the script that you worked with but expanded to work with individual Zenpages (rather than making separate pages and placing the code at the top).

Just an idea for the future development (I need to learn PHP, lol).




Login-Only Page? - sbillard - 2009-12-09

The gallery in not protected unless there is a gallery password no matter what you do with passwords. The best approach is to make the custom password script.




Login-Only Page? - statvoid - 2009-12-09

I have the galleries unpublished with the "personal-album" filter so only that user (and admins) can see that users' particular gallery.




Login-Only Page? - acrylian - 2009-12-09

If you unpublish Zenpage articles/pages also only logged in users will see those (same with images and albums).




Login-Only Page? - acrylian - 2009-12-09

Just to confirm, sbillard is actually right about the password form, that does the same as what I suggested unnecessarily. I missed indeed a detail as I don't use that too often. Happens even to developers....




Login-Only Page? - statvoid - 2009-12-09

Exactly what I was going for, for one.

And two, I totally overlooked the fact that there was an option to unpublish pages. My bad. lol.

Also, how do I get the link for the "register user" plugin to actually display the register link? The admin option says

If this option is not empty, the visitor login form will include a link to this page. The link text will be labeled with the text provided.

Problem is, there is no link to register (to click to go to the registration page) on my login page. I'm also using the "user_Login-out" plugin, could this be why (it doesn't provide a link to register)? If so, what script do I put in it's place so users can log in?




Login-Only Page? - acrylian - 2009-12-09

I am personally not familiar with that plugin, but most plugins are optional in that way that you have to add the function(s) of the plugin where you want them to appear. So the register function has to be added to whatever password page you setup. (see indeed the standard themes password.php page).




Login-Only Page? - statvoid - 2009-12-09

So I figured it out! But now, for some reason, when I register a new user they receive an email that contains a verification link, but all of the links bring up the following error:

Zenphoto Error: the requested object was not found. Page: PAGES: Return to Site
Any idea what I might have done wrong?




Login-Only Page? - statvoid - 2009-12-09

Nevermind! I got it! lol