I noticed that someone asked for a mod that allows specific group IDs to be excluded from post captcha (https://www.simplemachines.org/community/index.php?topic=574014.0).
This is something I implemented on one of my forums a few years ago because some members take out a Paid Subscription as soon as they join and I figured these members shouldn't have to complete captcha for posts (or PMs). Also, and because I'd actually migrated this particular forum from a vBulletin forum that had been in existence for a few years, I added an option to exclude members who had joined more than a specific time ago from having to complete captcha (some long term but not very active members who were still 'Newbies').
In ./Sources/Display.php
Find:
// Do we need to show the visual verification image?
$context['require_verification'] = !$user_info['is_mod'] && !$user_info['is_admin'] && !empty($modSettings['posts_require_captcha']) && ($user_info['posts'] < $modSettings['posts_require_captcha'] || ($user_info['is_guest'] && $modSettings['posts_require_captcha'] == -1));
Replace with:
// Do we need to show the visual verification image?
// Code to exclude post verification for specific group IDs and members who joined more than a specific time ago.
$context['require_verification'] = !$user_info['is_mod'] && !$user_info['is_admin'] && !empty($modSettings['posts_require_captcha']) && ($user_info['posts'] < $modSettings['posts_require_captcha'] || ($user_info['is_guest'] && $modSettings['posts_require_captcha'] == -1)) && !$user_info['no_post_captcha'] && !$user_info['bypass_captcha'];
In ./Sources/Load.php
Find:
// This is a logged in user, so definitely not a spider.
$user_info['possibly_robot'] = false;
Add After:
// Added code to exclude post and PM verification for specific group IDs and members who joined more than a specific time ago.
$groups_no_post_captcha = (!empty($modSettings['groups_no_post_captcha']) ? explode(',', $modSettings['groups_no_post_captcha'], 20) : array(-1));
$no_post_captcha = (in_array($user_settings['id_group'], $groups_no_post_captcha));
$groups_no_pm_captcha = (!empty($modSettings['groups_no_pm_captcha']) ? explode(',', $modSettings['groups_no_pm_captcha'], 20) : array(-1));
$no_pm_captcha = (in_array($user_settings['id_group'], $groups_no_pm_captcha));
$bypass_captcha = (!empty($modSettings['joined_days_no_captcha']) && $modSettings['joined_days_no_captcha'] > 0 && ($user_settings['date_registered'] < strtotime($modSettings['joined_days_no_captcha'] . ' days')));
Find:
if (isset($_COOKIE[$cookiename]))
$_COOKIE[$cookiename] = '';
Add Before:
// Added code to exclude post and PM verification for specific group IDs and members who joined more than a specific time ago.
$no_post_captcha = false;
$no_pm_captcha = false;
$bypass_captcha = false;
Find:
'permissions' => array(),
Add After:
// Added code to exclude post and PM verification for specific group IDs and members who joined more than a specific time ago.
'no_post_captcha' => $no_post_captcha,
'no_pm_captcha' => $no_pm_captcha,
'bypass_captcha' => $bypass_captcha,
In ./Sources/ManageSettings.php
Find:
array('check', 'guests_report_require_captcha'),
Add Before:
// Added code to exclude post verification for specific group IDs and members who joined more than a specific time ago.
array('text', 'groups_no_post_captcha'),
array('int', 'joined_days_no_captcha'),
Find:
'pm2' => array('int', 'pm_posts_verification'),
Add After:
// Added code to exclude PM verification for specific group IDs.
'pm4' => array('text', 'groups_no_pm_captcha'),
Find:
$save_vars['pm2'],
Add After:
$save_vars['pm4'],
In ./Sources/PersonalMessage.php
Find:
$context['require_verification'] = !$user_info['is_admin'] && !empty($modSettings['pm_posts_verification']) && $user_info['posts'] < $modSettings['pm_posts_verification'];
if ($context['require_verification'])
{
$verificationOptions = array(
Replace with:
// Added code to exclude PM verification for specific group IDs and members who joined more than a specific time ago.
$context['require_verification'] = !$user_info['is_admin'] && !empty($modSettings['pm_posts_verification']) && ($user_info['posts'] < $modSettings['pm_posts_verification'] && !$user_info['no_pm_captcha'] && !$user_info['bypass_captcha']);
if ($context['require_verification'])
{
$verificationOptions = array(
Find:
// Check whether we need to show the code again.
$context['require_verification'] = !$user_info['is_admin'] && !empty($modSettings['pm_posts_verification']) && $user_info['posts'] < $modSettings['pm_posts_verification'];
Replace With:
// Check whether we need to show the code again.
// Added code to exclude PM verification for specific group IDs and members who joined more than a specific time ago.
$context['require_verification'] = !$user_info['is_admin'] && !empty($modSettings['pm_posts_verification']) && ($user_info['posts'] < $modSettings['pm_posts_verification'] && $user_info['no_pm_captcha'] && !$user_info['bypass_captcha']);
Find:
// Wrong verification code?
if (!$user_info['is_admin'] && !empty($modSettings['pm_posts_verification']) && $user_info['posts'] < $modSettings['pm_posts_verification'])
Replace With:
// Wrong verification code?
// Added code to exclude PM verification for specific group IDs and members who joined more than a specific time ago.
if (!$user_info['is_admin'] && !empty($modSettings['pm_posts_verification']) && ($user_info['posts'] < $modSettings['pm_posts_verification'] && !$user_info['no_pm_captcha'] && !$user_info['bypass_captcha']))
In ./Sources/Post.php
Find:
// Do we need to show the visual verification image?
$context['require_verification'] = !$user_info['is_mod'] && !$user_info['is_admin'] && !empty($modSettings['posts_require_captcha']) && ($user_info['posts'] < $modSettings['posts_require_captcha'] || ($user_info['is_guest'] && $modSettings['posts_require_captcha'] == -1));
Replace With:
// Do we need to show the visual verification image?
// Added code to exclude post verification for specific group IDs and members who joined more than a specific time ago.
$context['require_verification'] = !$user_info['is_mod'] && !$user_info['is_admin'] && !empty($modSettings['posts_require_captcha']) && ($user_info['posts'] < $modSettings['posts_require_captcha'] || ($user_info['is_guest'] && $modSettings['posts_require_captcha'] == -1)) && !$user_info['no_post_captcha'] && !$user_info['bypass_captcha'];
Find:
// Wrong verification code?
if (!$user_info['is_admin'] && !$user_info['is_mod'] && !empty($modSettings['posts_require_captcha']) && ($user_info['posts'] < $modSettings['posts_require_captcha'] || ($user_info['is_guest'] && $modSettings['posts_require_captcha'] == -1)))
Replace With:
// Wrong verification code?
// Added code to exclude post verification for specific group IDs and members who joined more than a specific time ago.
if (!$user_info['is_admin'] && !$user_info['is_mod'] && !empty($modSettings['posts_require_captcha']) && ($user_info['posts'] < $modSettings['posts_require_captcha'] || ($user_info['is_guest'] && $modSettings['posts_require_captcha'] == -1)) && !$user_info['no_post_captcha'] && !$user_info['bypass_captcha'])
In ./Themes/default/languages/ManageSettings.english.php
Add to end of file (ie, before ?>):
// Text strings to exclude post and PM verification for specific group IDs and members who joined more than a specified time ago.
$txt['pm_posts_verification'] = 'Post count under which members must pass verification when sending personal messages<div class="smalltext">(0 for no limit, admins and group IDs listed below are exempt)</div>';
$txt['posts_require_captcha_desc'] = '(0 for no limit; moderators, group IDs listed below and members who joined more than the number of days shown below are exempt)';
$txt['groups_no_post_captcha'] = 'Group IDs to be excluded from post verification.<div class="smalltext">(Must be separated by comma. i.e. 1,2,4)</div>';
$txt['groups_no_pm_captcha'] = 'Group IDs to be excluded from PM verification.<div class="smalltext">(Must be separated by comma. i.e. 1,2,4)</div>';
$txt['joined_days_no_captcha'] = 'Number of days after which members joined they are excluded from post verification.<div class="smalltext">(0 for not excluded)</div>';
If the Anti-Spam-Links mod (https://custom.simplemachines.org/mods/index.php?mod=2404) is installed the captcha exclusions can also be applied to links as follows:
In ./Sources/Post.php
Find:
// Ugly but necessary.
// Takes into account moderation when deciding whether to show the post error.
if((($own_post && $user_info['is_guest']) || (!$own_post && empty($poster_id)) && $modSettings['anti_spam_links_guests'] == 1) || ((($own_post && !$user_info['is_guest']) || !$own_post && !empty($poster_id)) && !empty($modSettings['anti_spam_links_nolinks']) && $posts < $modSettings['anti_spam_links_nolinks']))
Replace With:
// Ugly but necessary.
// Takes into account moderation when deciding whether to show the post error.
// Don't include member if they belong to a group ID for whom post captcha doesn't apply or if they are allowed to bypass captcha because of their length of membership.
if ((($own_post && $user_info['is_guest']) || (!$own_post && empty($poster_id)) && $modSettings['anti_spam_links_guests'] == 1) || ((($own_post && !$user_info['is_guest']) || !$own_post && !empty($poster_id)) && !empty($modSettings['anti_spam_links_nolinks']) && $posts < $modSettings['anti_spam_links_nolinks']) && !$user_info['no_post_captcha'] && !$user_info['bypass_captcha'])
Find:
// Ugly but necessary.
// Takes into account moderation when deciding whether to show the post error.
if((($own_post && $user_info['is_guest']) || (!$own_post && empty($poster_id)) && $modSettings['anti_spam_links_guests'] == 1) || ((($own_post && !$user_info['is_guest']) || !$own_post && !empty($poster_id)) && !empty($modSettings['anti_spam_links_nolinks']) && $posts < $modSettings['anti_spam_links_nolinks']))
Replace With:
// Ugly but necessary.
// Takes into account moderation when deciding whether to show the post error.
// Don't include member if they belong to a group ID for whom post captcha doesn't apply or if they are allowed to bypass captcha because of their length of membership.
if ((($own_post && $user_info['is_guest']) || (!$own_post && empty($poster_id)) && $modSettings['anti_spam_links_guests'] == 1) || ((($own_post && !$user_info['is_guest']) || !$own_post && !empty($poster_id)) && !empty($modSettings['anti_spam_links_nolinks']) && $posts < $modSettings['anti_spam_links_nolinks']) && !$user_info['no_post_captcha'] && !$user_info['bypass_captcha'])
Find:
// Ugly but necessary.
// Takes into account moderation when deciding whether to show the post error.
if((($own_post && $user_info['is_guest']) || (!$own_post && empty($poster_id)) && $modSettings['anti_spam_links_guests'] == 1) || ((($own_post && !$user_info['is_guest']) || !$own_post && !empty($poster_id)) && !empty($modSettings['anti_spam_links_nolinks']) && $posts < $modSettings['anti_spam_links_nolinks']))
Replace With:
// Ugly but necessary.
// Takes into account moderation when deciding whether to show the post error.
// Don't include member if they belong to a group ID for whom post captcha doesn't apply or if they are allowed to bypass captcha because of their length of membership.
if ((($own_post && $user_info['is_guest']) || (!$own_post && empty($poster_id)) && $modSettings['anti_spam_links_guests'] == 1) || ((($own_post && !$user_info['is_guest']) || !$own_post && !empty($poster_id)) && !empty($modSettings['anti_spam_links_nolinks']) && $posts < $modSettings['anti_spam_links_nolinks']) && !$user_info['no_post_captcha'] && !$user_info['bypass_captcha'])
I was looking for something like this mod and finally I found it :) Thanks
thank you for this
and yeah I've run into that issue, quite annoying
but as Arantor pointed out, simply change mine and the persons post count ;)
Zitat von: shadav in August 23, 2020, 10:09:56 VORMITTAG
thank you for this
and yeah I've run into that issue, quite annoying
but as Arantor pointed out, simply change mine and the persons post count ;)
I developed this tip/trick after I migrated a forum that had +2500 members from vBulletin to SMF - the forum had been in existence for several years and about 450 of the members had paid subscriptions.
I guess I could have written some SQL to manually increase the post counts of long-term/financial members but this method allows the member's true post count to be shown and is not affected if the "Recount all member post counts" maintenance task is run.