2014-01-09, 05:13 PM
2014-01-10, 12:38 AM
I don't recommend you to do core edits, that's just extra trouble for when you want to update your platform, make use of hooks instead.
(Make sure to save it as FancyPlugin.php)
I guess this can be a good starting point. You can figure out the variable names in $data and set an error if required. I just took this code from a plug-in of mine and changed function names, I haven't personally tested it and I don't recommend using this on a live website before you make sure that it really works.
Edit: I just realized that there is a Minimum Message Length configuration variable as well. You can use the plugin approach to have custom value per usergroup I guess.
<?php
// Hooks
$plugins->add_hook('datahandler_post_validate_thread', 'FancyPlugin_content');
$plugins->add_hook('datahandler_post_validate_post', 'FancyPlugin_content');
function FancyPlugin_info(){
return array(
"name" => "Your fancy plug-in",
"description" => "Let's check some lengths",
"website" => "http://mybb.com",
"author" => "marcus",
"authorsite" => "http://mybb.com",
"guid" => "",
"version" => "1.0",
"compatibility" => "16*"
);
}
function FancyPlugin_content($data) {
global $mybb, $db;
// $data contains post/thread info
$data->set_error(print_r($data, true));
// $data->set_error('Error message')
return $data;
}
?>
(Make sure to save it as FancyPlugin.php)
I guess this can be a good starting point. You can figure out the variable names in $data and set an error if required. I just took this code from a plug-in of mine and changed function names, I haven't personally tested it and I don't recommend using this on a live website before you make sure that it really works.
Edit: I just realized that there is a Minimum Message Length configuration variable as well. You can use the plugin approach to have custom value per usergroup I guess.
2014-01-10, 11:50 AM
Thanks buddy but the issue is
will also check replies but I only want editpost and newthread
Thanks for your code
$plugins->add_hook('datahandler_post_validate_post', 'FancyPlugin_content');
will also check replies but I only want editpost and newthread
Thanks for your code
2014-01-10, 02:57 PM
$_SERVER['SCRIPT_FILENAME'] will do the trick, combined with basename.
<?php
// Hooks
$plugins->add_hook('datahandler_post_validate_thread', 'FancyPlugin_content');
$plugins->add_hook('datahandler_post_validate_post', 'FancyPlugin_content');
function FancyPlugin_info(){
return array(
"name" => "Your fancy plug-in",
"description" => "Let's check some lengths",
"website" => "http://mybb.com",
"author" => "marcus",
"authorsite" => "http://mybb.com",
"guid" => "",
"version" => "1.0",
"compatibility" => "16*"
);
}
function FancyPlugin_content($data) {
$script = basename($_SERVER["SCRIPT_FILENAME"]);
if ($script == 'editpost.php' || $script == 'newthread.php') {
if (strlen($data->data['message']) < 30) {
$data->set_error('Your message must be at least 30 characters long');
}
}
}
?>
2014-01-10, 03:12 PM
OMG buddy thank you so much I can't thank you enough for this code nobody seemed to know how to do that +1 from me and +100 thanks