Skip to:
Content
Pages
Categories
Search
Top
Bottom

Disallow topic creation but allow comments in certain forums


  • Chezzer
    Participant

    @chezzer

    Is there a plugin or a method I can use to disable topic creation on a certain forum? I want to have a news forum for all my news posts and only allow comments on the topics I create, but not allow any topics to be created by anyone else. I do want users to be able to create topics in my other forums though. I noticed that turning the forum into a category kind of adds that ability, but then it removes the news forum for the forum page, which I don’t want.

    I’ve been searching plugins and forums for the last couple hours without much luck. Any plugins that I’ve found that did this are way outdated and don’t seem to work correctly with new versions. I am using the newest version of wordpress and bbpress and in the middle of building a new theme from the ground up. Thanks for any advice anyone can provide.

Viewing 4 replies - 1 through 4 (of 4 total)

  • PinkishHue
    Participant

    @pinkishhue

    It does seem tricky to set this sort of thing up (hopefully to be improved in future versions of bbpress?).

    One way to do this, although not the most robust option, would be to simply hide the new topic form for everyone but keymasters/admins when viewing that particular forum.

    I will assume you are accessing your new topic form when viewing the individual forum (it’s trickier if you are using the new topic form where you choose which forum to post to instead of/as well as individual forms in each section. This is what’s used here on the bbpress.org forums for example. If you need a solution for this as well let us know, I’m sure someone can explain how to do that)

    This is just off the top of my head and not tested (hopefully someone more experienced will be able to advise better) – in wp-content/your-theme/bbpress/form-topic.php (create this file if it’s not already in your theme, copy the original from wp-content/plugins/bbpress/templates/default/bbpress/

    At the top of the file, after this code:

    <?php
    
    /**
     * New/Edit Topic
     *
     * @package bbPress
     * @subpackage Theme
     */
    
    ?>

    Add this code to check if you are in your news forum (here I’ve used forum id ‘5’ as an example, you’ll have to find the specific id for your forum) and if the user is an admin (there may be a better to do this using the keymaster role instead of the usual WP role but I don’t know about that):

    <?php if ( bbp_is_single_forum( '5' ) && current_user_can( 'manage_options' )) : ?>

    Then at the very end of the file close the if statement by adding this:

    <?php endif; ?>

    That should work as far as I know but I am still finding my way with bbpress so can’t say for definite. Good luck!


    Chezzer
    Participant

    @chezzer

    Thanks, this definitely helps get me on the right path. Since I am just removing the form to make new topics on the one forum, I don’t even need to worry about user permissions, I can block it for even the keymaster since I am using the bbPress Topics for Posts plugin which I have set to automatically make a news topic when I post a new blog post to the main page, which is all I need.

    I am still running into issues though. bbp_is_single_forum() doesn’t seem to take any arguments. I started looking at other possibilities and found the bbp_forum_title() function which returns “News” or whatever the name of my forum is, but it seems to only print it to screen and not give it to me in anyway I can actually do a string compare. Same thing with bbp_forum_id(). bbp_form_forum_title() and other things I’ve tried seem to return nothing. I’ve tried using strip_tags and trim but it still just prints to screen and ignores my if statement.

    This would be an ideal solution if I could just get the title string and do a string compare against “News” which then hide the form. I’m pretty new to php. I’ve got quite a bit of programming experience in other languages though, esp Java. So It’s likely I am just making a simple mistake with syntax or something.

    Thanks again. I’ll keep experimenting and see if I can figure out anything.


    Chezzer
    Participant

    @chezzer

    I just figured out what I needed. It turns out bbp_get_forum_title() returns a string that I can actually compare and it seems to work perfect. So my issues in my last message can be ignored.

    Just for clarity, this is what the final piece looks like:

    <?php if (bbp_get_forum_title() !== "News") : ?>

    Then I just add the endif you suggested at the end and it works great.

    Thanks again!

    Hi drillbell,

    I am happy to announce that you can now close forums in v1.0.3 of bbP Toolkit (https://wordpress.org/plugins/bbp-toolkit/)

    Pascal.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.