Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Changing the default page for unathenticated users?

dan39dan39 New
edited May 2008 in Vanilla 1.0 Help
If you have a private forum, and you want the unauthenticated users to be forwarded to an "about" page, for example, (rather than the sign-in page, which is currently the default behavior), how do you set that up? I feel like this should be pretty easy, but I don't want to do it incorrectly. Any help would be greatly appreciated. Thanks.

Comments

  • I bet its pretty easy too. I think you can make an extention and add just this tiny code to it: <code> if ($Context->Session->UserID == 0 ) // not logged in goto url </code> sorry for the pseudo code on the 2nd line, but im omw out and im sure you can find it if u look it up
  • dan39dan39 New
    edited March 2007
    Won't that interfere with the redirect that's being initiated by Vanilla's core? or would that override Vanilla's redirect?

    I think I found the part of the Vanilla Core that handles this (in library/People/People.Class.Session.php):

    function Check(&$Context) { if (($this->UserID == 0 && !$Context->Configuration['PUBLIC_BROWSING']) || ($this->UserID > 0 && !$this->User->PERMISSION_SIGN_IN)) { if ($this->UserID > 0 && !$this->User->PERMISSION_SIGN_IN) $this->End($Context->Authenticator); header('location: '.AppendUrlParameters($Context->Configuration['SAFE_REDIRECT'], 'ReturnUrl='.GetRequestUri())); die(); } }

    How exactly does one modify that and turn that into a sound extension? (Or is that not the way to go.)
  • OK, this is how I did it...

    1. Using PageManager, make the 2 pages, we'll call them MEMBER and GUEST.

    2. Using PageManager make another page we'll call it DOOR

    The PageManager DOOR contains this...
    <?php if ($this->Context->Session->UserID > 0) { $URL="http://path.to/forum/?Page=MEMBER"; header ("Location: $URL"); } else { $URL="http://path.to/forum/?Page=GUEST"; header ("Location: $URL"); } ?>

    3. One more step, in your .htaccess file put this...
    RewriteEngine On Options +FollowSymLinks -Multiviews RewriteCond %{QUERY_STRING} ^$ RewriteRule ^$ ?Page=DOOR [L]

    How does it work?
    The .htaccess file makes the PageManager page DOOR the default, it then discriminates between MEMBER or GUEST and re-directs accordingly.

    Simple enough? pic

    Posted: Sunday, 1 April 2007 at 3:37PM

  • dan39dan39 New
    edited April 2007
    Thanks Wanderer,

    But, your solution is a bit more than I needed. I already had an html page handy, so I just needed a simple redirect. I used Mr. Do's approach, but I used the logic from the People.Class.Session file to do a check to see if the forum was set to "Private" before performing the redirect on users that weren't logged in. I also allowed people.php to be exempt from the redirect so that users would be allowed to login.

    The addon is now available here for anyone who wants it.
  • gj Dan :)
  • edited August 2007
    this .htaccess business just flat out never works for me. . .

    Massive edit:
    I don't have mod_rewrite installed, apparently.

    This guide has a good paragraph on how to check to see if it's installed or not:
    http://www.workingwith.me.uk/articles/scripting/mod_rewrite
  • Can I use Wanderer's method to get Categories to be the default page on login (its a private forum). Any simpler method to do this?
  • This the the only method that worked for me (and I tried everything), simple if you understand it and very powerful and flexible too.

    Posted: Sunday, 9 September 2007 at 11:59AM

  • Wanderer, does this method work with friendly urls?
    thanks
  • All you really should need to do is change the $Context->Configuration['SAFE_REDIRECT'] to whatever URL you desire...

    The downside is that if your forum is public, SAFE_REDIRECT will never be used, but given the scenario that was set-up in the first post, we're dealing with private forum anyway.
  • ok, in my particular case, the forum is public and have to main starting pages (one for guests, another for logged users) both built over PageManager so i thought that Wanderer's solution could do the chance, but i can't manage it to work properly :(

    i have tried the default page extension, but i have a couple of issues with it

    (i' ve added the lines wanderer suggested in the .htaccess file that dinoboff showed somewhere here)
  • If you have followed my instructions properly this method does work.
    It's been in use on my forum for over a year and it works flawlessly.

    Changing the default page for unathenticated users? # 4

    Posted: Thursday, 29 May 2008 at 6:32AM

  • yes, it worked on my local test server, but on the external one didn't :(

    i'll try again tomorrow (1 a.m. here :P) to see if it's some incompatibility between the configuration in the httpd.conf and the .htaccess or what
This discussion has been closed.