Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

[GitHub #1051] How can I hide the 'Start a New Discussion'-button?

edited August 2011 in Vanilla 2.0 - 2.8
On my forum, members are only allowed to place comments on already opened threads. They are not allowed to start a new thread.

I set this up in the 'Roles & Permissions'-screen and everything works, but the 'Start a New Discussion'-button is still shown. How can I hide this button?

Please note: when an Administrator is logged in the button should be visible, since administrators are allowed to start a new thread.
Tagged:

Best Answer

  • UnderDogUnderDog MVP
    Answer ✓
    I'll sink the topic instead of closing it. If questions come up during development we can post them in here

    There was an error rendering this rich post.

Answers

  • All right, no answers so far...

    Let me put it otherwise: How can I read the current logged in user status, role and/or permissions? Because then I just edit views/modules/newdiscussion.php like:
    if($userIsAllowedToStartANewDiscussion)
    {
    echo Anchor(T('Start a New Discussion'), '/post/discussion'.(array_key_exists('CategoryID', $Data) ? '/'.$Data['CategoryID'] : ''), 'BigButton NewDiscussion');
    }
  • I got it, but I think this should be filed as a bug. Because when you don't give a user permission to add a new discussion, there also should not be any need for the 'Start a New Discussion'-button.

    The following code solved it:

    // Check the users permission:
    $Session = Gdn::Session();
    if($Session->CheckPermission('Vanilla.Discussions.Add'))
    {
    echo Anchor(T('Start a New Discussion'), '/post/discussion'.(array_key_exists('CategoryID', $Data) ? '/'.$Data['CategoryID'] : ''), 'BigButton NewDiscussion');
    }

  • lucluc ✭✭
    I got it, but I think this should be filed as a bug. Because when you don't give a user permission to add a new discussion, there also should not be any need for the 'Start a New Discussion'-button.

    The following code solved it:

    // Check the users permission:
    $Session = Gdn::Session();
    if($Session->CheckPermission('Vanilla.Discussions.Add'))
    {
    echo Anchor(T('Start a New Discussion'), '/post/discussion'.(array_key_exists('CategoryID', $Data) ? '/'.$Data['CategoryID'] : ''), 'BigButton NewDiscussion');
    }

    It's on purpose IIRC, it's an incentive for them to create a login.
  • I don't think you understand me correctly. Let me explain my situation:

    - I have adminstrators, who are king!
    - I have moderators, who can start new threads (assigned by the adminstrator)
    - I have members, who can only post comments on threads (they can register themselves)
    - And all the 'guests' who can only read the forum, but not post comments (they need to register to do that).

    So if somebody creates a login on the site, they are not allowed to create new threads, only comment on existing threads. I did this by unchecking the 'Add'-checkbox in the 'Roles & Permissions'-page » Members » Discussions. But the 'Start a New Discussion'-button was still visible. And clicking on the button resulted in an error that the user doesn't have the correct permissions.

    Therefore I think this should be considered as a bug.
  • lucluc ✭✭
    Indeed.
    Just use what you wrote up there to create an issue on github for the project.
    Otherwise, it will surely be forgotten.
  • filed

    please close this topic
  • UnderDogUnderDog MVP
    Answer ✓
    I'll sink the topic instead of closing it. If questions come up during development we can post them in here

    There was an error rendering this rich post.

  • This is a bug, not a "feature".

    A non-logged in user clicks the "add discussion" button, they go to the form to add, but the form shows no categories available, and the user cannot post but there is no message to say why, it just reloads the form.
Sign In or Register to comment.