Support » Plugin: Asgaros Forum » Hide New topic button on parent forum

  • Resolved laucoste

    (@laucoste)


    Hello,

    In my Asgaros structure, I have a forum (“parent”) including sub-forums. In this parent forum, all new topics have to be created in a sub-forum, in order to be well categorized.

    How to hide the New Topic button on the parent forum page ? The goal is to avoid the creation of new topics without inserting them into a sub-forum.

    Besides, another forums are existing, and they contain no sub-forum. So, the above need is only about 1 URL, the one of the parent forum. How could we filter the hiding on that precise parent forum / URL ?

    If a little CSS trick is possible, that would be great.

    Thanks a lot,

    Regards

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi,

    I’ve found a solution (I’m not developper so sorry if that’s not an optimal code). Maybe useful as a quick and dirty solution !
    Feel free to make it better or propose another solution.

    The change takes place in includes > forum.php :

    // Generate forum menu
    function showForumMenu() {
    $menu = ”;

    // Add below : currentpage, words, and detect
    // currentpage : URL of the parent page of the forum where to hide the New Topic button
    // words : Words to identify in the URL of the current page (specify a very unique string)
    // detect : Condition checking that “words” is present in the URL of the page

    $currentpage = $_SERVER[‘REQUEST_URI’] ;
    $words = ‘blah-blah’;
    $detect = strpos($currentpage, $words);

    if ($this->forumIsOpen()) {

    // If “blah-blah” not found in the URL, so the New Topic button has not to be hidden (we insert : $detect === false)

    if ((is_user_logged_in() && !$this->permissions->isBanned(‘current’) && $detect === false) || (!is_user_logged_in() && $this->options[‘allow_guest_postings’])) {

    $menu .= ‘<div class=”forum-menu”>’;
    $menu .= ‘get_link(‘addtopic’, $this->current_forum).'”>’;
    $menu .= ‘<span class=”menu-icon fas fa-plus-square”></span>’;
    $menu .= __(‘New Topic’, ‘asgaros-forum’);
    $menu .= ‘
    ‘;
    $menu .= ‘</div>’;
    }

    // Add this “else” : If “blah-blah” is found in the URL, so the New Topic button has not to be displayed
    else {
    $menu .= ‘<div class=”forum-menu”>’;
    $menu .= ‘</div>’;
    }

    }

    Plugin Author Asgaros

    (@asgaros)

    Hello @laucoste

    Have you tried to just set the status of this forum to “Closed”? In closed forums only administrators/moderators can create topics, normal users will not have access to this button. This setting also does not have any affect on subforums so it should be suitable for you. 🙂

    Hello @asgaros

    LoL ! OK, thank you… That suits my needs. I forget my super custom code 🙂

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