Member
Member
statvoid   2009-12-09, 17:05
#1

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.

Administrator
Administrator
acrylian   2009-12-09, 17:39
#2

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))) {...}

Member
Member
statvoid   2009-12-09, 17:45
#3

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).

Administrator
Administrator
acrylian   2009-12-09, 18:09
#4

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.

Member
Member
statvoid   2009-12-09, 18:43
#5

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

Member
Member
statvoid   2009-12-09, 19:06
#6

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?

Administrator
Administrator
acrylian   2009-12-09, 19:10
#7

Sorry, try exit instead of break.

Member
Member
sbillard   2009-12-09, 19:14
#8

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.

Administrator
Administrator
acrylian   2009-12-09, 19:39
#9

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.

Member
Member
statvoid   2009-12-09, 20:05
#10

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).

Member
Member
sbillard   2009-12-09, 20:14
#11

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.

Member
Member
statvoid   2009-12-09, 20:16
#12

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

Administrator
Administrator
acrylian   2009-12-09, 20:31
#13

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

Administrator
Administrator
acrylian   2009-12-09, 20:38
#14

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....

Member
Member
statvoid   2009-12-09, 20:46
#15

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?

Administrator
Administrator
acrylian   2009-12-09, 21:08
#16

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).

Member
Member
statvoid   2009-12-09, 21:59
#17

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?

Member
Member
statvoid   2009-12-09, 23:06
#18

Nevermind! I got it! lol

  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.