Jump to content

Unique Private Photo Gallery With User Login


NooseLadder
 Share

Recommended Posts

onjegolders, I have created a login and members section based on your code that you detailed earlier. In my page structure, I have something like this:

about

members

--bob

--andrew

contact

The members page is basically a placeholder. When bob logs in he goes to www.example.com/members/bob/. The members page shows up in the menu as www.example.com/members/. 

What would I need to do to make the menu link for members point to www.example.com/members/bob/ when bob is logged in? And to www.example.com/members/andrew/ when andrew is logged in?

Link to comment
Share on other sites

Hi Andrew,

If I understand what you want correctly, you'd do something like this:

if ($user->isLoggedin()) { ?>

  <a href="<?php echo $config->urls->root; ?>members/<?php echo $user->name; ?>">Profile</a>

<?php }

That will depend on there being a members page which links up to the user page. 

Alternatively if you want the URL to be /members (without the name) then just make each member use the members template. And just check at the top of the members template that the current logged-in user's name matches the page->name

if ($user->name == $page->name) {

  echo "Welcome back" . $page->title;

} else {

  echo "Please login";

}


If it does, then you can safely output all the user/member's information.

Link to comment
Share on other sites

A private photo gallery with user login is something that is asked for many times. I think this thread about it should have a summary and placed in Tutorials or FAQ. If somebody, or I can find the time to start collecting all the posts holding code examples and try to make a tutorial out of it.

  • Like 1
Link to comment
Share on other sites

onjegolders, thanks! That was exactly what I was looking for. And it ended up being pretty easy. I'm finally starting to understand php and pw.

I agree with you pwired. This does seem to be a frequently requested topic in the forums. 

Someone mentioned starting a repository of code snippets. Perhaps this could belong in there too.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...