Hi,
I had my forum locked for guests since long time...
I now want to open it,
All i want is that people could browse my whole forum as guest but they don't see Things/Lines which are inside CODE bb tag...
Can anyone help with it please
Edit- please check 5th post, slight modification needed.
Simplest way is to edit BBC code parsing so it uses different code for guest
Search for (there are multiple instances)
'tag' => 'code',
Next line will have something like
'content' => '<div class="codeheader">' . $txt['code'] . ': <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">' . $txt['code_select'] . '</a></div><code>$1</code>',
After "'content' => "
Add $user_info['is_guest'] ? 'Register to see codes!' :
Like this:
'content' => $user_info['is_guest'] ? 'Register to see codes!' : '<div class="codeheader">' . $txt['code'] . ': <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">' . $txt['code_select'] . '</a></div><code>$1</code>',
Do same for rest of code tags. After this they still can see code when quoting but it can be fixed by removing code sections before quoted code is shown. (ie. in un_preprasecode)
Hi Niko,
Am little weak at coding in php... though i can code...
Can you tell me which files to edit... or can i just attach the files... where modifications need to be done...
Am using smf 2.0 RC1
theme airymidnight
There are lots of mod's installed in the forum so i dont wana have things messed up... also about that quoting thing... guests aren permitted to post... so that won't do any problem isn't it?
Guests can view whole forum(only view) and can't view things inside code tags, i want there to say please register to see link which my registration link...
Can you please do it for me... i really need that
if yes please let me know which files to attach
Edits Niko mentioned should go in Subs.php file.
Thanks for the above solution they were working cool.
Now i want a new modification in that.
If a person is unregistered he shall see "Register to see download link" but if he is registered and have post count less than 5, it shall say "You need minimum of 5 post to download from this forum".
I hope to hear a solution from you guys soon please. :)
Ok lets suppose i made a post group named newbie at post count 5.
As you checked for guest as ['is_guest'] , tell me how to check for group newbie. I'll handle rest code.
Brother can you make it simple in a code like, if(){true statement}else{false statement}
Tell me what to enter inside if statement to check for my condition, than i'll nest it with my previous guest one.
'content' => in_array(4, $user_info['groups']) ? 'Register to see codes!' : '<div class="codeheader">' . $txt['code'] . ': <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">' . $txt['code_select'] . '</a></div><code>$1</code>',
Assuming your newbie group's ID is 4, this should work.
Thats a smart move bro. I'll replace 4 with my group id and test in few days. Actually i'll nest it with old one to impose seperate restrictions for below newbie group. If registration check is passed than it ll check for that group ;)
You could also use the $user_info['posts'] variable to check post count of the member like instead of
in_array(4, $user_info['groups'])
you could use:
$user_info['posts'] < 5
Quote
'content' =>$user_info['is_guest'] ? 'Register to see codes!' :$user_info['posts'] < 5 ? 'You need minimum of 5 posts to see links' : '<div class="codeheader">' . $txt['code'] . ': ($2) <a href="#" onclick="return smfSelectText(this);" class="codeoperation">' . $txt['code_select'] . '</a></div><code>$1</code>',
Can you guys correct this code please??
i want it to work like
Quote
if($user_info['is_guest'])
{
Register to see codes!
}
else
{
if($user_info['posts'] < 5)
{
You need minimum of 5 posts to see links
}
}
That means if user is guest... he see message as "Register to see link"
else if user is not guest but have post less than 5... he see message as "You need minimum of 5 posts to see links"
rest user see the post normaly.
currently am getting output from the code as
You needs minimum of 5 posts to see links even if user is guest.
Somehow conditions are not looping inside each other..
I need it done urgently please
'content' => $user_info['is_guest'] ? 'Register to see codes!' : ($user_info['posts'] < 5 ? 'You need minimum of 5 posts to see links!' : '<div class="codeheader">' . $txt['code'] . ': <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">' . $txt['code_select'] . '</a></div><code>$1</code>'),
I know this is an old thread and please forgive me for bring it up, but I am trying to find a way to do this with [url][/url]
working with SMF 2.0.14 in Subs.php if you find these lines
'content' => '<div class="codeheader">' . $txt['code'] . ': <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">' . $txt['code_select'] . '</a></div>' . ($context['browser']['is_gecko'] || $context['browser']['is_opera'] ? '<pre style="margin: 0; padding: 0;">' : '') . '<code class="bbc_code">$1</code>' . ($context['browser']['is_gecko'] || $context['browser']['is_opera'] ? '</pre>' : ''),
and
'content' => '<div class="codeheader">' . $txt['code'] . ': <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">' . $txt['code_select'] . '</a></div>' . ($context['browser']['is_gecko'] || $context['browser']['is_opera'] ? '<pre style="margin: 0; padding: 0;">' : '') . '<code class="bbc_code">$1</code>' . ($context['browser']['is_gecko'] || $context['browser']['is_opera'] ? '</pre>' : ''),
and add
$user_info['posts'] < 5 ? '<b>You need a 5 post minimum to see code and url tags! </b>' :
like so:
'content' => $user_info['posts'] < 5 ? '<b>You need a 5 post minimum to see code and url tags! </b>' : '<div class="codeheader">' . $txt['code'] . ': <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">' . $txt['code_select'] . '</a></div>' . ($context['browser']['is_gecko'] || $context['browser']['is_opera'] ? '<pre style="margin: 0; padding: 0;">' : '') . '<code class="bbc_code">$1</code>' . ($context['browser']['is_gecko'] || $context['browser']['is_opera'] ? '</pre>' : ''),
'content' => < 5 ? '<b>You need a 5 post minimum to see code and url tags! </b>' : '<div class="codeheader">' . $txt['code'] . ': <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">' . $txt['code_select'] . '</a></div>' . ($context['browser']['is_gecko'] || $context['browser']['is_opera'] ? '<pre style="margin: 0; padding: 0;">' : '') . '<code class="bbc_code">$1</code>' . ($context['browser']['is_gecko'] || $context['browser']['is_opera'] ? '</pre>' : ''),
it works well to hide code tags stuff from users with less then 5 posts, but how can one go about hiding urls from user with less then 5 posts, I have tried to play with url tags but I got no luck on this
array(
'tag' => 'url',
'type' => 'unparsed_content',
'content' => '<a href="$1" class="bbc_link" target="_blank">$1</a>',
'validate' => create_function('&$tag, &$data, $disabled', '
$data = strtr($data, array(\'<br />\' => \'\'));
if (strpos($data, \'http://\') !== 0 && strpos($data, \'https://\') !== 0)
$data = \'http://\' . $data;
'),
),
'tag' => 'url',
'type' => 'unparsed_equals',
'before' => '<a href="$1" class="bbc_link" target="_blank">',
'after' => '</a>',
'validate' => create_function('&$tag, &$data, $disabled', '
if (strpos($data, \'http://\') !== 0 && strpos($data, \'https://\') !== 0)
$data = \'http://\' . $data;
'),
'disallow_children' => array('email', 'ftp', 'url', 'iurl'),
'disabled_after' => ' ($1)',
),
array(
'tag' => 'white',
'before' => '<span style="color: white;" class="bbc_color">',
'after' => '</span>',
),
);
any help would be greatly appreciated, and again sorry for dragging up an old post but it was close to the topic I was looking for.