I wanted to allow guest posting, using the various anti-bot measures, but disallow them posting links. At the same time, I wanted to stop new users posting links, until they had made a certain number of posts.
There are a few mods about, which almost satisfied these criteria, but not quite.
Interlog's posts on this topic were very useful:
http://www.phpbb.com/community/viewtopi ... 2&t=745615
I would have posted on Tumba25's thread, but it was locked:
http://www.phpbb.com/community/viewtopi ... &t=1576205
Here's my solution:
SQL
Code: Select all
INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('links_after_num_posts', '0', '0');
Code: Select all
// Start session management
$user->session_begin();
$auth->acl($user->data);
Code: Select all
$StopMe = "No";
if ($user->data['user_type'] == USER_IGNORE || $user->data['user_id'] == ANONYMOUS || $user->data['user_posts'] <= $config['links_after_num_posts']
){
$StopMe = "Yes";
}
Code: Select all
if ($submit || $preview || $refresh)
{
Code: Select all
$MHT = utf8_normalize_nfc(request_var('message', '', true));
if ($StopMe == "Yes" && (strpos($MHT,"http://") || (strpos($MHT,"www.")))){
trigger_error ("Oops... You can not post links. New users must wait until they have enough posts. Guests cannot post links.");
}
if ($StopMe == "Yes" && substr($MHT, 0, 4) == "www."){
trigger_error ("Oops... You can not post links. New users must wait until they have enough posts. Guests cannot post links.");
}
Find:
Code: Select all
'allow_post_links' => array('lang' => 'ALLOW_POST_LINKS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
Code: Select all
'links_after_num_posts' => array('lang' => 'LINKS_AFTER_NUM_POSTS', 'validate' => 'int:0', 'type' => 'text:4:4', 'explain' => true),
Find:
Code: Select all
'TOPICS_PER_PAGE' => 'Topics per page',
Code: Select all
'LINKS_AFTER_NUM_POSTS' => 'Min post count before posting links',
'LINKS_AFTER_NUM_POSTS_EXPLAIN' => 'Users will need this number of posts before they are able to use the [URL] BBCode tag and automatic/magic URLs.',
This allows the number of posts, before posting links, to be set in the ACP. Guests will never be able to post them. Some would ask why allow guests to post at all, but that is a different topic for discussion.
I don't know if anyone would like to take all this info, and produce an approved mod?
Thanks to Erik Frerejean for his help with the code, and apologies if I have not credited others for their work.