MyBB Community Forums
Set maximum character lenght in a particular forum - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: Extensions (https://community.mybb.com/forum-201.html)
+--- Forum: Plugins (https://community.mybb.com/forum-73.html)
+---- Forum: Plugin Requests (https://community.mybb.com/forum-65.html)
+---- Thread: Set maximum character lenght in a particular forum (/thread-217282.html)

Pages: 1 2


Set maximum character lenght in a particular forum - kbilly - 2018-05-01

Hello everyone!

On my forum,members need to introduce themselves before accessing to other forums/section.

SO,now comes the problem,some spammer selling credit cards will make a new account everyday and will post his orange spam in the introduction thread.

I would like to set a maximum lenght of characters in this way that spammer can't post his long annoying story of selling credit cards and bla bla bla.

I found a post where some member made a threadlimit.php to set the minimum lenght but i need the maximum lenght like 30-40 character limit and if more than that,then it will give error like:

Don't spam ecc ecc.

This plugin must function only in the introduction thread.

Thankyou


RE: Set maximum character lenght in a particular forum - Downfall - 2018-05-02

Rather than imposing these kinds of restrictions, you may want to look into enabling Stop Forum Spam checks on your forum. If you go into the Admin Control Panel, then Configuration » Board Settings » Stop Forum Spam.

You can enable checking against Stop Forum Spam. This should enable you to control the amount of spammers that are actually able to register. It works really well for us, at a time when we were getting hundreds of spam registrations per day.

Let me know if you need any help.


RE: Set maximum character lenght in a particular forum - kbilly - 2018-05-02

(2018-05-02, 12:31 AM)Downfall Wrote: Rather than imposing these kinds of restrictions, you may want to look into enabling Stop Forum Spam checks on your forum. If you go into the Admin Control Panel, then Configuration » Board Settings » Stop Forum Spam.

You can enable checking against Stop Forum Spam. This should enable you to control the amount of spammers that are actually able to register. It works really well for us, at a time when we were getting hundreds of spam registrations per day.

Let me know if you need any help.

Well bro,all that have been activated since a year and works very well but if a spammer uses a new proxy everyday and new username everyday,you can't stop him.

So,i'm still looking for it.

Here is the thread with minimum message lenght plugin.

https://community.mybb.com/thread-149762.html


Regards!


RE: Set maximum character lenght in a particular forum - kbilly - 2018-05-06

Well,nobody can help?


RE: Set maximum character lenght in a particular forum - Wires - 2018-05-06

The code on how to do this is literally posted on the thread you linked. What are you unsure about? Make a new .php file called threadlimit.php and place the code in the file. The file must be located in inc/plugins/ directory. Edit the line:

Quote: $minimum_characters = 200; // Edit number of minimum characters here

to your desired amount.


RE: Set maximum character lenght in a particular forum - kbilly - 2018-05-06

(2018-05-06, 12:38 PM)Wires Wrote: The code on how to do this is literally posted on the thread you linked. What are you unsure about? Make a new .php file called threadlimit.php and place the code in the file. The file must be located in inc/plugins/ directory.  Edit the line:

Quote:    $minimum_characters = 200; // Edit number of minimum characters here

to your desired amount.

Are you sure that you have understood what i'm looking for?

However,i have already modified the plugin from minimum amount to maximum,now the next step is to activate it in a particular forum if it is doable..otherwise,i am ok with it as it is.

Regards!


RE: Set maximum character lenght in a particular forum - Wires - 2018-05-06

Try this, I haven't tested it but it should work:

<?php

if(!defined("IN_MYBB"))
    exit;

$plugins->add_hook("newthread_do_newthread_start", "threadlimit_run");

function threadlimit_info()
{
    return array(
        'name'            => 'Thread Message Length',
        'description'    => 'Only allow threads to be posted if they\'re over a certain length',
        'website'        => '',
        'author'        => 'Wires <i>(AndreRl)</i>',
        'authorsite'    => '',
        'version'        => '2.0',
        'guid'             => '',
        'compatibility' => '*'
    );
}

function threadlimit_activate() {
global $db;

$threadlimit_group = array(
        'gid'    => 'NULL',
        'name'  => 'threadlimit',
        'title'      => 'Thread Limit Plugin',
        'description'    => 'Settings For Thread Limit',
        'disporder'    => "1",
        'isdefault'  => "0",
    ); 

$db->insert_query('settinggroups', $threadlimit_group);
 $gid = $db->insert_id(); 

$threadlimit_setting = array(
        'sid'            => 'NULL',
        'name'        => 'threadlimit_forums',
        'title'            => 'Forum Select',
        'description'    => 'Select forums where this plugin will be used in',
        'optionscode'    => 'forumselect',
        'value'        => '',
        'disporder'        => 1,
        'gid'            => intval($gid),
    ); 
$threadlimit_setting2 = array(
        'sid'            => 'NULL',
        'name'        => 'threadlimit_characters',
        'title'            => 'Characters',
        'description'    => 'Set character limit to be used.',
        'optionscode'    => 'text',
        'value'        => 200,
        'disporder'        => 1,
        'gid'            => intval($gid),
    ); 
$db->insert_query('settings', $threadlimit_setting);
$db->insert_query('settings', $threadlimit_setting2);
  rebuild_settings();
} 

function threadlimit_deactivate()
{
  global $db;
 $db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN ('threadlimit_forums', 'threadlimit_characters')");
    $db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='threadlimit'");
rebuild_settings();
}

function threadlimit_run()
{
    global $mybb;
    $maximum_characters = $mybb->settings['threadlimit_characters'];
 $limitforums = explode(',', $mybb->settings['threadlimit_forums']);
 $forumid = $mybb->get_input('fid', MyBB::INPUT_INT);
    $chars = strlen($mybb->input['message']);

    if (in_array($forumid, $limitforums) && $chars >= $maximum_characters || $mybb->settings['threadlimit_forums'] == '-1')
 {
        error('Your thread message must contain a maximum of ' . $maximum_characters . ' characters to continue. It currently is ' . $chars . ' characters.');
}
}

?>

Also changed the author name to my own. Only thing that's the same in this code is the function name tbh.


RE: Set maximum character lenght in a particular forum - kbilly - 2018-05-07

Hello and thanks for helping me.

I installed it but getting the following errors:

   

I posted this screenshot,in this way,you can have an idea of what's the problem.

Thankyou again!


RE: Set maximum character lenght in a particular forum - Wires - 2018-05-07

Fixed, updated my post.


RE: Set maximum character lenght in a particular forum - kbilly - 2018-05-07

Now comes the other problem..i have 14 characters but i can't post even when the maximum is set to 20.