Please or Register to create posts and topics.

Hide New topic button on parent forum

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

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 .= ‘<a class=”button button-normal forum-editor-button” href=”‘.$this->get_link(‘addtopic’, $this->current_forum).'”>’;
$menu .= ‘<span class=”menu-icon fas fa-plus-square”></span>’;
$menu .= __(‘New Topic’, ‘asgaros-forum’);
$menu .= ‘</a>’;
$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>’;
}

}

Hi @alcandau

Just for reference a link to my answer here:

https://wordpress.org/support/topic/hide-new-topic-button-on-parent-forum/#post-12009658

If you want to support the development of Asgaros Forum, you can leave a good review or donate. Thank you very much!