PDA

View Full Version : Scan New Posts For Hide Tags


Dj Smuggla
10-01-2010, 10:58 AM
Im using a hide hack on my forum & its hard to make members use it, especially new members.

So is there anychance a coder could knock up a quick lil script, that scans a members post for [HIDE] tags when they click
'Submit New Thread'.

If there's no hide tags in the message area, the member gets a error saying 'You must use hide tags in your message'
& their post does not get submitted.

I've just found another site that uses something like this, check the attached screen.

Thanks

BirdOPrey5
10-01-2010, 05:06 PM
OMG why would you force someone to use HIDE tags if they don't want to? If you don't want non-members viewing threads you can set the permissions to keep them out.

Dj Smuggla
10-01-2010, 06:43 PM
Thats the rules on my site. You hide a part of the thread, members reply & then can see the unhidden content.

Anyway all thats sorted my hide hack works perfectly, i just need a script that checks if the member has used them & gives a error if they havent. Like i stated in the first post^^^

Would that be somthing you could take a look at BirdOPrey5

BirdOPrey5
10-01-2010, 07:33 PM
I could code the part where it would look for the "[HIDE]" tag no problem, but getting it to return an error instead of post is still beyond me at the moment...

kh99
10-01-2010, 08:15 PM
OK Try this:

1. Create a phrase for your error message text and for Phrase Type choose "Error Messages". Let's say the varname is must_use_hide (or if you use something else, also change it in the code below).

2. Create a plugin using the newpost_process hook with this code:

if (!preg_match('|\.+\|', $post['message']))
{
$dataman->error('must_use_hide');
}

I tested it a little but I hate doing regular expressions so it may not be 100% correct, so maybe BirdOfPrey has a good way to check for HIDE tags.

BirdOPrey5
10-01-2010, 10:54 PM
I'm sure your method is more efficient, I was just going to search for the closing tag because if they use that they probably use the opening too but your implementation is better.

Dj Smuggla
10-02-2010, 11:30 AM
Thanks guys for taking a look...

kh99 that works great m8 :D, but how do you add more of these:
''|\.+\|','

Because right now i have to use the hide in caps like in the code above.

Is it possible to add:
[hide]
[hiDE]

One last thing, how can i use it only in a certain set of forums, not every forum.

Thanks again m8, gud stuff...

kh99
10-02-2010, 12:07 PM
For the hide, HiDe, etc issue, you just need to add an 'i' at the end of the pattern. You have access to the $foruminfo, so if you want to do it only for certain forums you can check $foruminfo['forumid']. There was one other problem in the above: newpost_process is actually called for all posts and not just new threads, so there needs to be a check for that.


if ($type == 'thread' AND in_array($foruminfo['forumid'], array(1, 2, 3)))
{
if (!preg_match('|\.+\|i', $post['message']))
{
$dataman->error('must_use_hide');
}
}


Of course you want to replace the 1, 2, 3 list with your list of fourm ids. If there's some other forum option to check you might be able to do that instead of checking for certain ids.

Dj Smuggla
10-02-2010, 12:19 PM
Thanks a million kh99, that worked perfect m8... :D

That'll save me & my mods a lot of time editing posts...