Minimum post characters?

Started by Furry, April 06, 2008, 04:54:17 AM

Previous topic - Next topic

Furry

I was looking through administration trying to find an option to set the minimum amount of characters a user needs in their post, but ran out of luck.

I saw a mod that did this, but it's out of date and won't work with 2.0. I'm wondering, is there's actually a built in feature that I didn't see, or an update for this mod that I'm unaware of?

EDIT: To add to this, I did a bit of searching around and found some code in post.php:


elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength'])
$post_errors[] = 'long_message';


That, I'm guessing is the code checking to long messages, would it be difficult to use this to check for an insufficient amount of text as well?


codenaught

Sure.

After that you could add something like:

elseif ($smcFunc['strlen']($_POST['message']) < 5)
  $post_errors[] = 'short_message';


Then in Themes/default/languages/Errors.english.php you can add somewhere in the file:

$txt['error_short_message'] = 'The message does not have the minimum number of characters required of 5.';

Of course adjusting the 5 to what you want and the error message to whatever you want.
Dev Consultant
Former SMF Doc Coordinator

xyxis_fahim

Can the earlier version be edited to fit 2.0?
Tnx

codenaught

Do you mean the mod offers some type of functionality that the code hack I posted doesn't have or you just don't want to manually edit the code?

You would have to ask the author of the mod about the mod being updated for 2.0.
Dev Consultant
Former SMF Doc Coordinator

xyxis_fahim

Well,
This is the mod I speak of.

http://custom.simplemachines.org/mods/index.php?mod=290

I will try contacting the Author.

Thanks.

Furry

Many thanks akabugeyes, this works nicely. :D

Aileen

elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength'])
$post_errors[] = 'long_message';

elseif ($smcFunc['strlen']($_POST['message']) < 5)
  $post_errors[] = 'short_message';



Should the code look like this? since it is under?


BTW where to place this


Thanks


Any instruction for a non-developer?

Advertisement: