MyBB Community Forums

Full Version: Modify this function so that the links in a single forum is not being blocked?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
The function is:
function registeredlinks_process(&$message)
{
	global $lang, $mybb;
	

	if (in_array($mybb->usergroup['gid'], array('1', '5', '7', '12')))
	{
		$lang->load('registeredlinks');
		
		$lang->reglinks_text = str_replace("{bburl}",$mybb->settings['bburl'],$lang->reglinks_text);
		
		$message = preg_replace('#<a href="(.*?)</a>#i', $lang->reglinks_text, $message);
		

	}
	
	
	return $message;

}

I want all links in the forum hidden from certain user groups, except for a single parent forum group...I want all, including guests to be able to see the links in that forum.

Is there a relatively easy way to implement that in this code?
I'm going to give it a shot... Tell me how bad it is. Smile

function registeredlinks_process(&$message)
{
	global $lang, $mybb;
	
    if ($mybb->forum['pid'] == 70)
	elseif (in_array($mybb->usergroup['gid'], array('1', '5', '7', '12')))
	{
		$lang->load('registeredlinks');
		
		$lang->reglinks_text = str_replace("{bburl}",$mybb->settings['bburl'],$lang->reglinks_text);
		
		$message = preg_replace('#<a href="(.*?)</a>#i', $lang->reglinks_text, $message);
		

	}
	
	
	return $message;

}
if you wanted to hide links in forum 70 for user groups 1, 5, 7, 12 then below code should work

global $lang, $mybb, $forum;
if ($forum['fid'] == 70) && if (in_array($mybb->usergroup['gid'], array('1', '5', '7', '12')))
{ required code segment } 


global $lang, $mybb, $forum;
if ($forum['fid'] == 70 && in_array($mybb->usergroup['gid'], array('1', '5', '7', '12')))
{ required code segment } 
(2013-10-22, 04:29 PM).m. Wrote: [ -> ]if you wanted to hide links in forum 70 for user groups 1, 5, 7, 12 then below code should work

global $lang, $mybb, $forum;
if ($forum['fid'] == 70) && if (in_array($mybb->usergroup['gid'], array('1', '5', '7', '12')))
{ required code segment } 

What I want to do is hide links in all forums EXCEPT for category/parent forum 70.

So I want 70 to show links to everyone.

Ahhh... So then I would do this:

global $lang, $mybb, $forum;
if ($forum['pid'] != 70) && if (in_array($mybb->usergroup['gid'], array('1', '5', '7', '12')))
{ required code segment } 

yes? Smile
^ yes, that should work.
Hmmm.. That crashes the forum completely. No error or nothing. Just returns a completely blank page no matter where I try to go. I trial and error several times and it's definitely not liking it. I tried with $forum[fid] as well (as opposed to [pid]).

Any ideas?

<?php
/*
Registered Links
by: vbgamer45
http://www.mybbhacks.com
Copyright 2010  MyBBHacks.com

############################################
License Information:
if ($mybb->user['uid'] == 0)
Links to http://www.mybbhacks.com must remain unless
branding free option is purchased.
#############################################
*/
if(!defined('IN_MYBB'))
	die('This file cannot be accessed directly.');
	
$plugins->add_hook("parse_message", "registeredlinks_process");

function registeredlinks_info()
{

	return array(
		"name"		=> "Registered Links",
		"description"		=> "Hides all links from guests requires them to register in order to view",
		"website"		=> "http://www.mybbhacks.com",
		"author"		=> "vbgamer45",
		"authorsite"		=> "http://www.mybbhacks.com",
		"version"		=> "1.0",
		"guid" 			=> "7725ba33bb01a4223b01fe0ee022d650",
		"compatibility"	=> "1*"
		);
}


function registeredlinks_install()
{

	

}



function registeredlinks_uninstall()
{

}




function registeredlinks_process(&$message)
{
	global $lang, $mybb, $forum;
	if ($forum['fid'] != 70) && if (in_array($mybb->usergroup['gid'], array('1', '5', '7', '12')))
	{
		$lang->load('registeredlinks');
		
		$lang->reglinks_text = str_replace("{bburl}",$mybb->settings['bburl'],$lang->reglinks_text);
		
		$message = preg_replace('#<a href="(.*?)</a>#i', $lang->reglinks_text, $message);
		

	}
	
	
	return $message;

}


?>
try changing
if ($forum['fid'] != 70) && if (in_array($mybb->usergroup['gid'], array('1', '5', '7', '12')))
to this
if ($forum['fid'] != 70 && in_array($mybb->usergroup['gid'], array('1', '5', '7', '12')))
Ahhh... That works. I ending up using [pid] as well, and forums under that parent are able to see the links, but all other links in other forums are hidden.

Thanks again.
Many thanks to .m. This was a huge help. Can anyone help me with the correct expression to make this multiple forums?

I mean, for example: if $forum['fid'] !=70,30,34 && ......

I tried the above and it crashed the site,

So I tried if $forum['fid] != array('70','100') && ....

but that didn't work at all.

EDIT: I've also tried: if ($forum['pid'] != 70 || $forum['fid'] != 100 && ....

but that didn't work either :|

Thanks in advance
if (!in_array($forum['fid'], array(70, 30, 34)) && in_array($mybb->usergroup['gid'], array(1, 5, 7, 12))) 
Thanks destroy666. This works....

I'm completely perplexed as to how.... previously I had != (not equal to).. So it seems your code would do exactly the opposite of what i wanted...But it doesn't... I can't wrap my head around it... Sad

What if i wanted all forum links to be blocked to guests, except in CATEGORY 70 and FORUM 100?
Pages: 1 2