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.

Land on first page, but need to sign-in to read

edited October 2006 in Vanilla 1.0 Help
Hi, I wanted to check if it would be possible to configure vanilla, so that unauthenticated users can come to first page, to see all the discussion topics but would need to sign in, to read the discussions and also to comment. At the moment if I uncheck the configuration 'Allow non-members to browse the forum', the visitor is taken directly to sign-in form, but I want him to come to front page to see all the discussion topics and sign in to read them. Something like it happens in on forum at softwareceo.com http://www.softwareceo.com/forums/forumdisplay.php?f=4 Thanks a lot in advance. - Vinx

Comments

  • MarkMark Vanilla Staff
    You can make an extension to do that quite easily.

    Something like:

    if ($Context->Session->UserID == 0 && !in_array($Context->SelfUrl, array(people.php, index.php)) { header('location: '.AppendUrlParameters($Context->Configuration['SAFE_REDIRECT'], 'ReturnUrl='.GetRequestUri())); die(); }
  • edited October 2006
    Thanks Mark for your quick response. I hope I was knowledgeable enough to do that, but for now me poor self need more guidance.
  • MarkMark Vanilla Staff
    Go into your extensions folder and create a new folder called something like "SignInToRead".

    Open up the folder and create a new file called "default.php".

    Open up default.php and put this inside:

    <?php /* Extension Name: Sign In To Read Extension Url: http://lussumo.com/addons Description: Makes it so that unauthenticated users can see the discussions, but not the comments. Version: 1.0 Author: Mark O'Sullivan Author Url: http://lussumo.com */ if ($Context->Session->UserID == 0 && !in_array($Context->SelfUrl, array(people.php, index.php)) { header('location: '.AppendUrlParameters($Context->Configuration['SAFE_REDIRECT'], 'ReturnUrl='.GetRequestUri())); die(); } ?>

    Save the file. Then sign into vanilla as an administrator and go to the settings tab > extensions. Find the extension in the list and enable it.
  • edited October 2006
    Thanks Mark for the extention. I think it needs a bit of tuning, at present it gets into recursive loop and ends up with message cannot find the server. http://localhost/vanilla/people.php?PageAction=SignOutNow&ReturnUrl=/vanilla/people.php?PageAction=SignOutNow&ReturnUrl= /vanilla/people.php?PageAction=SignOutNow&amp;ReturnUrl=/vanilla/people.php?PageAction=SignOutNow&amp;amp;ReturnUrl= /vanilla/people.php?PageAction=SignOutNow&amp;amp;amp;ReturnUrl=/vanilla/people.php?PageAction=SignOutNow&amp;amp;amp;amp;ReturnUrl= /vanilla/people.php?PageAction=SignOutNow&amp;amp;amp;amp;amp;ReturnUrl=/vanilla/people.php?PageAction= SignOutNow&amp;amp;amp;amp;amp;amp;ReturnUrl=/vanilla/people.php?PageAction=SignOutNow&amp;amp;amp;amp;amp;amp;amp;ReturnUrl= /vanilla/people.php?PageAction=SignOutNow&amp;amp;amp;amp;amp;amp;amp;amp;ReturnUrl=/vanilla/people.php?PageAction= SignOutNow&amp;amp;amp;amp;amp;amp;amp;amp;amp;ReturnUrl=/vanilla/people.php?PageAction= SignOutNow&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;ReturnUrl=/vanilla/people.php?PageAction= SignOutNow&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;ReturnUrl=/vanilla/people.php?PageAction= SignOutNow&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;ReturnUrl=/vanilla/people.php?PageAction= SignOutNow&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;ReturnUrl=/vanilla/people.php?PageAction= SignOutNow&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;ReturnUrl=/vanilla/people.php?PageAction= SignOutNow&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;ReturnUrl=/vanilla/people.php?PageAction= SignOutNow&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;ReturnUrl=/vanilla/people.php?PageAction= SignOutNow&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;ReturnUrl=/vanilla/people.php?PageAction= SignOutNow&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;ReturnUrl=http://localhost/vanilla/
  • Loaded nothing but blank pages for me.
  • MarkMark Vanilla Staff
    Alright, let's try this one:

    <?php /* Extension Name: Sign In To Read Extension Url: http://lussumo.com/addons Description: Makes it so that unauthenticated users can see the discussions, but not the comments. Version: 1.0 Author: Mark O'Sullivan Author Url: http://lussumo.com */ if ($Context->Session->UserID == 0 && !in_array($Context->SelfUrl, array(people.php, index.php)) { header('location: people.php?ReturnUrl=index.php'); die(); } ?>
  • Heh, still gives me blank pages.
  • edited October 2006
    Its not working for me either, Mark I think it enters into a loop which never completes. - Vinx
  • I dont see how, the script refers you back to people.php only if you're not on people.php or index.php. So any page you go to besides them should send you to people.php which is one of them and that should be the end of it. Wierd.
  • edited October 2006
    # Minisweeper, you made me think. Now i see whats the issue. 1 - 'Allow non-members to browse the forum' should be checked. 2 - array(people.php, index.php) should be array('people.php', 'index.php') Code that works for me as below. <?php /* Extension Name: Sign In To Read Extension Url: http://lussumo.com/addons Description: Makes it so that unauthenticated users can see the discussions, but not the comments. Version: 1.0 Author: Mark O'Sullivan Author Url: http://lussumo.com */ if ($Context->Session->UserID == 0 && !in_array($Context->SelfUrl, array('people.php', 'index.php'))) { header('location: people.php?ReturnUrl=index.php'); die(); } ?> Mark, A BIG thank you. - Vinx
  • Also Friendly URL and this extention doesn't work together.
  • I dont see why not?
  • Adding the missing ")" and putting the pages in single quotes worked. Works for me now.
This discussion has been closed.