So the title say's it all if you want to stop a user with a post count lower than "10" for example posting in specific section's of the forum then this is how you do it.
Now when your in the back end of your site looking at the categories manager you notice how every forum categorie has it's own ID, For example "General Discussion" has the ID of "2".
In the following line's of code where it says :
Code:
if ( $check == "2" || $check == "3" || $check == "4" || $check == "5" ) {
Just replace the ID number's with what ever the ID's of your forum categories you wish to block.
Add the following lines of code to the file paths of your Kunena forum.
components/com_kunena/funcs/showcat.php Line 172 :
Code:
if (CKunenaTools::isModerator ( $this->my->id, $this->catid ) || !$this->kunena_forum_locked) {
$check = JRequest::getVar('catid');
$user =& JFactory::getUser();
$usr_id = $user->get('id');
$database = &JFactory::getDbo();
$database->setQuery("SELECT posts FROM #__kunena_users WHERE userid='$usr_id'");
$posts = (int)$database->loadResult();
if ( $check == "2" || $check == "3" || $check == "4" || $check == "5" ) {
if ( $posts >= "10" ) {
$this->forum_new = CKunenaLink::GetPostNewTopicLink ( $this->catid, CKunenaTools::showButton ( 'newtopic', JText::_('COM_KUNENA_BUTTON_NEW_TOPIC') ), 'nofollow', 'kicon-button kbuttoncomm btn-left', JText::_('COM_KUNENA_BUTTON_NEW_TOPIC_LONG') );
}
} else {
$this->forum_new = CKunenaLink::GetPostNewTopicLink ( $this->catid, CKunenaTools::showButton ( 'newtopic', JText::_('COM_KUNENA_BUTTON_NEW_TOPIC') ), 'nofollow', 'kicon-button kbuttoncomm btn-left', JText::_('COM_KUNENA_BUTTON_NEW_TOPIC_LONG') );
}
}
components/com_kunena/template/defualt/view/view.php (Be easyer just to replace the content of the entire file with the following.)
Code:
<?php
// Dont allow direct linking
defined( '_JEXEC' ) or die();
$user =& JFactory::getUser();
$check = JRequest::getVar('catid');
$usr_id = $user->get('id');
$database = &JFactory::getDbo();
$database->setQuery("SELECT posts FROM #__kunena_users WHERE userid='$usr_id'");
$posts = (int)$database->loadResult();
$document = JFactory::getDocument ();
$document->addScriptDeclaration('// <![CDATA[
var kunena_anonymous_name = "'.JText::_('COM_KUNENA_USERNAME_ANONYMOUS').'";
// ]]>');
?>
<div><?php $this->displayPathway(); ?></div>
<?php if($check == "2" || $check == "3" || $check == "4" || $check == "5"): ?>
<?php if($posts >= "10"): ?>
<?php if ($this->headerdesc) : ?>
<div id="kforum-head" class="<?php echo isset ( $this->catinfo->class_sfx ) ? ' kforum-headerdesc' . $this->escape($this->catinfo->class_sfx) : '' ?>">
<?php echo $this->headerdesc ?>
</div>
<?php endif ?>
<?php
$this->displayPoll();
CKunenaTools::showModulePosition( 'kunena_poll' );
$this->displayThreadActions(0);
?>
<div class="kblock">
<div class="kheader">
<h2><span><?php echo JText::_('COM_KUNENA_TOPIC') ?> <?php echo $this->escape($this->kunena_topic_title) ?></span></h2>
<?php if ($this->favorited) : ?><div class="kfavorite"></div><?php endif ?>
</div>
<div class="kcontainer">
<div class="kbody">
<?php foreach ( $this->messages as $message ) $this->displayMessage($message) ?>
</div>
</div>
</div>
<?php $this->displayThreadActions(1); ?>
<div class = "kforum-pathway-bottom">
<?php echo $this->kunena_pathway1; ?>
</div>
<?php else: ?>
<div class="kblock">
<div class="kheader">
<h2><span>Hidden Content :</span></h2>
</div>
<div class="kcontainer">
<div class="kbody">
<div class="khelprulescontent">
<center><b>You need more than 10 posts to access the content here.</b></center>
</div>
</div>
</div>
</div>
<?php endif; ?>
<?php else: ?>
<?php if ($this->headerdesc) : ?>
<div id="kforum-head" class="<?php echo isset ( $this->catinfo->class_sfx ) ? ' kforum-headerdesc' . $this->escape($this->catinfo->class_sfx) : '' ?>">
<?php echo $this->headerdesc ?>
</div>
<?php endif ?>
<?php
$this->displayPoll();
CKunenaTools::showModulePosition( 'kunena_poll' );
$this->displayThreadActions(0);
?>
<div class="kblock">
<div class="kheader">
<h2><span><?php echo JText::_('COM_KUNENA_TOPIC') ?> <?php echo $this->escape($this->kunena_topic_title) ?></span></h2>
<?php if ($this->favorited) : ?><div class="kfavorite"></div><?php endif ?>
</div>
<div class="kcontainer">
<div class="kbody">
<?php foreach ( $this->messages as $message ) $this->displayMessage($message) ?>
</div>
</div>
</div>
<?php $this->displayThreadActions(1); ?>
<div class = "kforum-pathway-bottom">
<?php echo $this->kunena_pathway1; ?>
</div>
<?php endif; ?>
<div class="kcontainer klist-bottom">
<div class="kbody">
<div class="kmoderatorslist-jump fltrt">
<?php $this->displayForumJump (); ?>
</div>
<?php if (!empty ( $this->modslist ) ) : ?>
<div class="klist-moderators">
<?php
echo '' . JText::_('COM_KUNENA_GEN_MODERATORS') . ": ";
$modlinks = array();
foreach ( $this->modslist as $mod ) {
$modlinks[] = CKunenaLink::GetProfileLink ( intval($mod->userid) );
}
echo implode(', ', $modlinks);
?>
</div>
<?php endif; ?>
</div>
</div>