K5.1.1 is released (10 Jun 2018)

The Kunena team is pleased to announce Kunena 5.1.1 [K 5.1.1].
Please read the blog post for information:

× Please note: The Kunena project team takes NO responsibility for maintaining nor supporting anything in this category.

Question Kunena Hide tags Hack Force Reply / Thanks to view hidden content

  • C0n
  • C0n's Avatar Topic Author
  • Offline
  • Premium Member
  • Only the strongest will survive
3 years 3 months ago - 3 years 3 months ago #1 by C0n
So i wrote this up for Kunena 1.6 / 7 About 3-4 years ago but decided to start adding it back into my own forum and decided i will share with you all so be greatfull. B)

Original old outdated version is here : www.kunena.org/forum/k-1-6-and-k-1-7-mis...-view-hidden-content

What the hide hack does is for users who create post's on the forum using "Hide Tags" it quiries if they have replied or not to the topic yet before it grants them access to view the hidden content. (Brilliant little feature against leechers and content scrappers.), This shall also allow users to know what members are gaining access to the content they provide on the forum hence the fact other members have to reply / give thanks to the topic or post to view the content.

Feature List :
  • Force reply to view hidden content of posts in a topic
  • Choose to either reply to topic or click the Thanks button
  • Set user post count requirement to view hidden contents. (
    Part of the message is hidden for the guests. Please log in or register to see it.

I am still getting to grips with the changes in Kunena's Code but this is the working version so far.

\public_html\libraries\kunena\bbcode\bbcode.php (Lines : 1006 function dohide)
function DoHide($bbcode, $action, $name, $default, $params, $content) {
		if ($action == BBCODE_CHECK)
			return true;
		if (!empty($bbcode->lost_start_tags[$name]) && !$bbcode->was_limited) {
			return "[{$name}]{$content}";
		// Display nothing in activity streams etc..
		if (!empty($bbcode->parent->forceSecure)) {
		if (JFactory::getUser ()->id == 0) {
			// Hide between content from non registered users
			return '</br>' . JText::_ ( 'COM_KUNENA_BBCODE_HIDDENTEXT' );
		} else {
$user =& JFactory::getUser();
$usr_id = $user->get('id');
$lol = JRequest::getVar('id');
$database = &JFactory::getDbo();
$maxpost = 100;
$database->setQuery("SELECT thread FROM #__kunena_messages WHERE userid='$usr_id' AND thread='$lol'", 0, 1);
$threads = $database->loadResult();
$database->setQuery("SELECT postid FROM #__kunena_thankyou WHERE userid='$usr_id' AND postid='$lol'", 0, 1);
$thankyou = $database->loadResult();
$database->setQuery("SELECT posts FROM #__kunena_users WHERE userid='$usr_id'");
$posts = (int)$database->loadResult();
$me = KunenaUserHelper::getMyself();
if (($me->userid && $bbcode->parent->message->userid == $me->userid) || $me->isModerator(isset($bbcode->parent->message) ? $bbcode->parent->message->getCategory() : null)) {
return '</br><b>' . JText::_ ( 'COM_KUNENA_BBCODE_HIDE_IN_MESSAGE' ) . '</b>' . '<div class="kmsgtext-hide">' . $content . '</div>';
} else { /*
if (isset (['default'])) {
$tempstr = ['default'];
if ($tempstr > $maxpost)
$tempstr = $maxpost;
if ( $posts >= $tempstr ) {
return '</br><b>' . JText::_ ( 'COM_KUNENA_BBCODE_HIDE_IN_MESSAGE' ) . '</b>' . '<div class="kmsgtext-hide">' . $content . '</div>';
} else {
return '</br><b>' . JText::_ ( 'COM_KUNENA_BBCODE_HIDE_IN_MESSAGE' ) . '</b>' . '<div class="kmsgtext-hide">You require ' . $tempstr . ' posts in order to view the content contained Here.</div>';
} else { */
if ( $threads == $lol || $thankyou == $lol ) {
return '</br><b>' . JText::_ ( 'COM_KUNENA_BBCODE_HIDE_IN_MESSAGE' ) . '</b>' . '<div class="kmsgtext-hide">' . $content . '</div>';
} else {
return '</br><b>' . JText::_ ( 'COM_KUNENA_BBCODE_HIDE_IN_MESSAGE' ) . '</b>' . '<div class="kmsgtext-hide">You Must Reply to this topic or give Thanks in order to view the content contained Here.</div>';
			// Display but highlight the fact that it is hidden from guests
			//return '</br><b>' . JText::_ ( 'COM_KUNENA_BBCODE_HIDE_IN_MESSAGE' ) . '</b>' . '<div class="kmsgtext-hide">' . $content . '</div>';

The reason i currently have a section of code nulled out is because i am still trying to get the hide for post count feature to work. Just like i did with the previous kunena, I am sure i will get my head around it soon.

Current Bug's / Issues :
  1. BBcode on hide hack for post count requirement
    does not seem to want to work.

  2. Kunena Caching posts, Prevents user from viewing content they just replied / gave thanks to until cache expires. (Need to find a way around this without disabling caches.)

Perhaps a Kunena Dev can tell me what the equivalant for new kunena from the previous BBCode to detect if a code tag had a string attached.
In the old version
if (isset ( $tag->options ['default'] )) {

Slowly figuring it out.
'hide' => array(
				'mode' => BBCODE_MODE_LIBRARY,
				'method' => 'DoHide',
				'allow' => array('_default' => '/^\d*$/'),
				'class' => 'block',
				'allow_in' => array('listitem', 'block', 'columns'),
				'content' => BBCODE_REQUIRED,
				'plain_content' => array(),
Last edit: 3 years 3 months ago by C0n.

Please Log in or Create an account to join the conversation.

  • Not Allowed: to create new topic.
  • Not Allowed: to reply.
  • Not Allowed: to add attachements.
  • Not Allowed: to edit your message.
Time to create page: 0.073 seconds