Skip to:
Content
Pages
Categories
Search
Top
Bottom

Hide “New Topic” Form on Certain Pages


  • bradm413
    Participant

    @bradm413

    bbPress Version 2.6.9
    WP version 5.8.2
    site: https://branchtheworld.com

    I have searched and haven’t found an exact case like what I’m looking for. I would like to hide the “New Topic” form that displays when using this shortcode:

    [bbp-single-forum id=$forum_id] – Display a single forums topics. eg. [bbp-single-forum id=32]

    See screenshot here:
    screenshot

    Is this something I’ll need to do with custom coding, or is there a plugin or another simple way to achieve this?

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

  • Robin W
    Moderator

    @robin-w

    so do you want to hide the new topic form every time this particular forum displays (easier), or just for this particular shortcode on a page (more difficult) ?


    bradm413
    Participant

    @bradm413

    Ideally, I would like to dynamically hide this New Topic form, based on my needs. Since that is the more difficult path, can you just give me a high-level idea of where to start? I have built a local unpublished plugin before, so I can go down that route if I need to.

    And the for the easier option, how would I just hide it every time for now?

    Thanks!


    Robin W
    Moderator

    @robin-w

    Untested, but find
    wp-content/plugins/bbpress/templates/default/bbpress/form-topic.php

    transfer this to your pc and edit

    change line 31

    from

    <?php if ( bbp_current_user_can_access_create_topic_form() ) : ?>

    to

    <?php if ( bbp_current_user_can_access_create_topic_form() && (bbp_get_forum_id() != '2927') ) : ?>

    and save

    where 2927 is the forum you don’t want to show the form for

    then create a directory on your theme called ‘bbpress’
    ie wp-content/themes/%your-theme-name%/bbpress

    where %your-theme-name% is the name of your theme

    Then transfer the file you saved above and put in in the directory called bbpress that you created above, so you end up with
    wp-content/themes/%your-theme-name%/bbpress/form-topic.php

    bbPress will now use this template instead of the original

    If you want multiple forums, you could create and array and test against that

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