Fork me on GitHub
Current release is 2.1.6 (21 Nov 2014).

Users who have not yet upgraded to 2.1 should get security release 2.0.18.14 (1 Nov 2014). We will stop providing these security releases to 2.0 at the end of this year.

Always show "Start a New Discussion" button, even for guests?

edited May 2012 in Vanilla 2.0 Help

Is this too broad a question? I don't have anything else to say except for asking the question!

Best Answer

  • peregrineperegrine ☯ hasta luego :) In-Flight MVP
    edited May 2012 Answer ✓

    Option 1

    I mean changing the code and adding to it ...

    Check if user is logged in and display the button (normally you wouldn't see it - correct). If a user is logged in they wouldn't see it. So you are not changing the original Start New discussion code - just merely adding the button if no one is logged in (guest status).

    If not logged in display Start New discussion - that links to signin

    essentially what you said you wanted.

    If you are not up for programming a change.

    Option 2

    The alternative and second option

    You could download the anonymouse plugin - it allows people to post if they are not members - they merely have to respond to a captcha code (personally I find it easier to log in), but some users don't want to be members and that gives them the option to post.

    Monetary Donations will be appreciated if you use my plugins. Thanks in Advance.
    As a waiter gets a tip for a good meal, tips for successful solutions appreciated as well. click here for Peregrine | click here for FAQ

Answers

  • peregrineperegrine ☯ hasta luego :) In-Flight MVP

    guests are defined as users who can only view. Anyone who is not logged in is considered a guest. Try the anonymouse plugin if you want people to post messages without becoming members,

    Monetary Donations will be appreciated if you use my plugins. Thanks in Advance.
    As a waiter gets a tip for a good meal, tips for successful solutions appreciated as well. click here for Peregrine | click here for FAQ

    Marc905
  • peregrine said: guests are defined as users who can only view. Anyone who is not logged in is considered a guest. Try the anonymouse plugin if you want people to post messages without becoming members, Hi peregrine,

    Thanks for your answer! I realize now that it was not clear what I was asking. I would actually like to show the button, but not allow the user to post. He or she would be brought to the sign in/ register page upon clicking the "Start a New Discussion" button.

    My aim is to encourage participation in the forum this way.

  • peregrineperegrine ☯ hasta luego :) In-Flight MVP
    edited May 2012

    Best I can do for you...

    You have to experiment....

    apparently this is the code for the new discussion button:

    echo Anchor(T('Start a New Discussion'), '/post/discussion'.(array_key_exists('CategoryID', $Data) ? '/'.$Data['CategoryID'] : ''), 'BigButton NewDiscussion');

    this is the signin destination... http://localhost/vanilla/entry/signin?Target=discussions

    perhaps if you merged them somewhere - you might get what you want.

    Monetary Donations will be appreciated if you use my plugins. Thanks in Advance.
    As a waiter gets a tip for a good meal, tips for successful solutions appreciated as well. click here for Peregrine | click here for FAQ

  • I think I understand you. If I understand correctly, your solution overlooks the fact that the button is not displayed for guests. Do you mean to use that anonymouse plugin to enable displaying of the "Start a New Discussion" button for guests? The problem here would be that if I changed this code —

    echo Anchor(T('Start a New Discussion'), '/post/discussion'.(array_key_exists('CategoryID', $Data) ? '/'.$Data['CategoryID'] : ''), 'BigButton NewDiscussion');

    — then I would be changing it for the logged in users as well, no?

    Do you follow me? Thanks for the info. (I'm brand new with Vanilla and absolutely loving learning it:))

  • edited May 2012

    I might actually try the anonymouse plugin in order to encourage registrations in the early days. Thanks for the information. I'll be back to implement option 1 later, and hopefully this is helpful for others who may want the same functionality!

    edit: On second thought, I'm going to try Option 1, as suggested, and I'll get back with my results. Like I said, I'm a complete newbie so we'll see how long it takes me to figure it all out.

  • peregrine said: Option 1

    I mean changing the code and adding to it ...

    Check if user is logged in and display the button (normally you wouldn't see it - correct). If a user is logged in they wouldn't see it. So you are not changing the original Start New discussion code - just merely adding the button if no one is logged in (guest status).

    If not logged in display Start New discussion - that links to signin

    I've been messing around with /vanilla/applications/vanilla/views/modules/newdiscussion.php and trying to write some code that identifies guests. However I just realized that newdiscussion.php doesn't seem to even get called if the user is a guest, so there's no point in editing it until I can tell Vanilla to call that file for guests also. That's where I'm at. Appreciate it if you had any thoughts on direction from here. I'll follow up if I find out where to go from here.

  • Answer

    This is literally the easiest solution.

    1. Open /vanilla/applications/vanilla/modules/class.newdiscussionmodule.php
    2. Comment out line 18: if ($HasPermission)

    So now Vanilla won't check if the user has permissions to see the "Start a New Discussion" button; it'll just display it no matter what. And if a guest clicks that button he's brought to the Sign in page.

    Unfortunately I already selected peregrine's option as the answer and I can't revoke that, but this is the solution that works for me. Wouldn't have gotten here without your support, peregrine, cheers!

  • edited May 2012

    In addition to above, the following change is possible to make the "Start a New Discussion" go directly to the Register page for Guests. However, it's probably not a good practice to implement this, because logged-out users would be brought to the register page upon clicking the button, and they wouldn't be able to sign in from that page.

    Change /vanilla/applications/vanilla/views/modules/newdiscussion.php to the following:

    <?php if (!defined('APPLICATION')) exit();
    
    if (Gdn::Session()->CheckPermission('Vanilla.Comments.Add', TRUE, 'Category', $CategoryID)) {
     echo Anchor(T('Ask a Question'), '/post/discussion'.(array_key_exists('CategoryID', $Data) ? '/'.$Data['CategoryID'] : ''), 'BigButton NewDiscussion');
    }
    else {
     echo Anchor(T('Ask a Question'), '/entry/register'.(array_key_exists('CategoryID', $Data) ? '/'.$Data['CategoryID'] : ''), 'BigButton NewDiscussion');
    }
    
Sign In or Register to comment.