1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Walled Garden 0.1

Discussion in 'Plugins' started by Nick, Apr 1, 2010.

  1. Nick

    Nick Well-Known Member

    Walled Garden
    Version: 0.1
    Author: Nick Ramsay
    Created: 2010/04/01
    Last Updated:
    Tested on: Hotaru 1.1.3 ~ 1.3.0
    Plugins Required: User Signin
    Plug & Play: Yes
    Supported: Yes

    A simple plugin to prevent non-registered users accessing your site. If they try to, they are redirected to the login page. They can, of course, access the registration page.

    Thanks to ties for the inspiration.

    1. Upload the "walled_garden" folder to your plugins folder.
    2. Install it from Plugin Management in Admin.

    Revision History
    v.0.1 2010/04/01 - Nick - Released first version

    Attached Files:

  2. ties

    ties Theme & Plugin Development

    lol i never saw this as a plugin because its so easy to do, but i think its easier for people this way
    thanks for the credits :p nice name btw
    hint: if you want to add more pages visible to your guests add pagenames to this array
            $allowed_pages = array('login''register''logout''emailconf');
    Last edited: Apr 1, 2010
    Nick likes this.
  3. Nick

    Nick Well-Known Member

    Good point ties. For example, if you are using the Contact Us plugin, you might want to add 'contact' to that list of allowed pages.
  4. hotaruuser

    hotaruuser New Member

    Hi there!

    At the moment this plugin prevents unlogged users from entering sites, which are not in the allow_pages array.

    But if you want to restrict the access to few pages only, is it not possible to change the following line in the walled_garden.php:

    if (!$h->currentUser->loggedIn && [B]!in_array[/B]($h->pageName, $allowed_pages)) {
    if (!$h->currentUser->loggedIn && [B]in_array[/B]($h->pageName, $allowed_pages)) {
    so the allowed_pages variable is turned into a "disallowed_pages"? For example only the user profiles? I am no expert, but if I find time to try it on testpage, I tell you if it works
  5. hotaruuser

    hotaruuser New Member


    It is possible to turn the pages into disallowed pages, just check for the page type and page name with a correct if-statement. In my test it worked well, when I found the right code...

    But it is possible to use the existing walled garden as it is, but to allow posts to be seen from non-registered users?


    I found it. Posts are in pageType = posts, so adding an if-statement should do it:

            if (!$h->currentUser->loggedIn && !in_array($h->pageName, $allowed_pages)) { 
                if (!$h->pageType == 'post') {
                    header("Location: " . $h->url(array('page'=>'login')));
                    die(); exit;
    Last edited: Aug 3, 2011
  6. hotaruuser

    hotaruuser New Member

    Sorry, I found a strange thing, if I change the walled_garden.php like this above, the user profiles are visible for non-logged in too! Don't know why...


    It is because of the if-statement, pure logical thing, you can't add a third statement to the code.
    I had to make a negative statement from it, so every page which was not allowed to see for non-registered, had to be wrote in the array. Works fine
    Last edited: Aug 7, 2011

Share This Page