Creating and implementing post count policies for users and groups in phpBB

phpBB has lots of features and some are very obscure. I ran into one of these recently for a client. Apparently, it’s possible for users and groups to not have their posts count in their total post count.

Obviously this is not an issue for most boards, and it’s hard to figure out a use case for why you would want to do this. One case is to avoid unearned ranks. phpBB has an optional ranking system which is typically based on the number of posts. Making lots of replies that aren’t really substantive can do this and it’s an issue on some boards. Presumably these boards are not well moderated, as moderators are usually tasked to find and remove these posts.

Whether a post is counted in a user’s total post count or not depends on whether the post_postcount column in the phpbb_posts table is 0 or 1. If it’s 1, it gets counted. If it’s 0, it doesn’t get counted.

For example, you could have a general chat forum and posts in these forums might not want to be counted in a user’s total posts because they are considered trite. Then you could have other forums where the meat of the board’s content is, and posts in these forums could count.

Changing the post count policy

By default, all posts count in a user’s total post count, so if you don’t want posts to count for certain groups or users, you will have to change phpBB’s settings.

This is controlled by a permission. Typically you set this group forum permission. ACP > Forums > Forum based permissions > Group forum permissions.

Next you pick the group, then the forums for the group where the permission will be changed. Next you select the Advanced permissions link and then click on the Post tab. Then set the Increment post counter setting to either Yes or No as desired for the group and the forum. Do this for all the forums whose permission you want to change for the group and save your changes. If you want to change this permission for other groups, repeat.

Increment post counter permission

If you want to remove this permission for a particular user or users only, you can avoid groups by selecting ACP > Forums > Forum based permissions > User forum permissions. In general though I think you’d want to avoid doing this on a user-by-user basis, and do this only for groups.

Changing post counts for old posts

While this works for future posts, it doesn’t affect existing posts. How do you fix these old bogus post counts? As best I can tell there is no extension to help you out. So you have to get down and dirty with your database, using a tool like phpMyAdmin.

Before attempting anything like this, disable your board and back up your database, or at least backup the posts table. This can be done in the ACP on the Maintenance tab.

Generally you need a list of forum_ids and group_ids. A tool like phpMyAdmin makes it simple to look inside your database. Your web host control panel will usually have a tool that runs phpMyAdmin. Make sure you select the database for your board. Your board’s config.php file will provide the database name, if there is any ambiguity.

Database tools like phpMyAdmin are very powerful. It is possible to make large, irreversible changes to the database if you type commands incorrectly.

A forum_id is a number assigned to a forum in the database. You can see a list of forum_ids with this query, which can be executed on the SQL tab for your database in phpMyAdmin. (Change phpbb_ if your table prefix is different):

SELECT forum_id, forum_name FROM phpbb_forums;

Getting forum_id for forums in phpMyAdmin

Next, you need a similar query to get the group_ids for your groups:

SELECT group_id, group_name FROM phpbb_groups;

Getting group_id for groups in phpMyAdmin

With these group_id and forum_id values, you can then write a query to change the post_postcount value in the phpbb_posts table for a particular group and forum. Using the example above, if you wanted to change this flag to 0 (don’t count) for all members in the Registered users group (group_id = 2) to the forum “Your first forum” forum (forum_id = 2), the SQL would be:

UPDATE phpbb_posts p, phpbb_groups g, phpbb_forums f, phpbb_user_group ug
SET post_postcount = 0
WHERE p.forum_id = f.forum_id AND
p.poster_id = ug.user_id AND ug.group_id = 2 AND f.forum_id = 2

If you wanted to set post_postcount to 0 (zero) for all posts made in a forum, the SQL is somewhat simpler. In the case of forum_id = 2 the SQL would be:

UPDATE phpbb_posts p, phpbb_forums f
SET post_postcount = 0
WHERE p.forum_id = f.forum_id AND f.forum_id = 2

Recalculating the post counts

There is one last step: you need to recalculate these statistics:

ACP > General > Resynchronise post counts

Clean up

If you messed up, restore the table you backed up.

Also, if you disabled your board, reenable it.

February 2021 work summary

February was a busy month. Here’s a summary of my activity last month for various clients:

  • Updated a board from phpBB from version 3.3.2 to 3.3.3. No extensions needed updating. No new Italian language pack needed to be installed either.
  • Upgraded a board from phpBB 3.0.12 to 3.3.3. Installed and configured Tapatalk and Cleantalk extensions, tested Tapatalk. Installed Absolution style, but created a custom style based on it. Placed ad at top, reused logo image and added a number of custom items to the navigation menu. Changed text in the footer to show in black otherwise it couldn’t be seen. Added some FontAwesome icons for use on the navigation bar. Later, I fixed a navigation bar issue, as menu items only showed when logged in.
  • Fixed a variety of invalid HTML issues by fixing templates. Then I fixed an issue brought up by the Google Search console on the breadcrumb list with a value for ID being required, testing on a Google tool site. Later in the month, I updated a different board from phpBB 3.3.1 to 3.3.3. In this job, I updated the AllanStyle-SUBSILVER style and made changes to the custom style to fix the same Google breadcrumb issue. I updated the Google Analytics extension to version 1.0.6 so G key could be entered, and my Digests extension from version 3.3.2 to 3.3.4.
  • Originally I planned to convert a client’s phpBB 2 board, but he bought the book and did it himself. He was kind enough to send a donation, however.
  • Upgraded board from phpBB 3.0.12 to 3.3.3. I installed the Elegance Green style, then created custom style to inherit from it to which I applied style tweaks. I tried to make the style look similar, mostly in colors, to the old board. Read/unread icons have a red image (in part) that I couldn’t fix because I couldn’t get Artodia’s colorizer to upload a 3.3.0 archive and fix that. I fixed colors where possible. I set a new logo provided by client, placed on left instead of center. I enabled reCAPTCHA V3 and disabled the contact form. Changed PHP to 7.4. No issues during upgrade. Pushed margins most of the way across page similar to the old look.
  • Updated board with a prosilver style from phpBB 3.3.0 to 3.3.3. Then I updated Cleantalk from 5.7.2 to 5.7.3 and Tapatalk from 2.1.7 to 2.1.8. I change captcha from reCaptcha V2 to V3. I added back code to show the logo to stylesheet.css.
  • Updated a board from phpBB 3.3.1 to 3.3.3. Updated the Multi-design style from version 1.0.5 to 1.1.5, which is built for phpBB 3.3. I added one line in stylesheet.css for the style to hide the logo, like before. I also uploaded ads.txt to web root as requested to support Google Adsense and upgraded the PiWigo gallery software and PiWigo extension by simply clicking on two links.
  • Installed Magic OGP links: thumbnails and descriptions extension to a board. I added permissions for registered users to allow them to thank posters on forums where they were missing.
  • Upgrade a board from phpBB 3.0.4 to 3.3.3. Since reverting to PHP 5 was not an option, I had to make changes to database manually, fixing issues with styles and templates tables. There was one phpbb_config table row problem that occurred running the upgrade program. I spent a lot of time getting the styling to reflect the red wine color. I also installed the pages extension and converted two static pages to it, moving code to BBCode. I configured reCAPTCHA V3 and disabled the contact form.
  • Errors came up on a board, likely due to Hostgator changing PHP default to 7.4. His style does not appear to be available for phpBB 3.3 so I updated him from phpBB 3.2.1 to 3.2.11. I tried to change PHP to 7.2 but it doesn’t stick, at least ACP shows 7.0 is being used. I had to upgrade the Media Embed extension to get it to come up. If PHP and style issue can be resolved, I will credit this toward an upgrade to phpBB 3.3.
  • Installed phpBB on a forums subdomain on Siteground hosting. Installed phpBB 3.3.3 and the proflat style. Inherited proflat style to create a custom style. Installed reCaptcha V3 and disabled the contact form. Tested email, set it up similar to how I have it set up on my Siteground hosting. I set up a couple of dozen forums inside a number of categories per outline provided. I spent a long time getting the styling right. Incorporated provided logo. Also, sold client a PDF of my book.
  • Changed changed to a different class of GoDaddy hosting and there installed phpBB with the hosts’s auto installer. But what he really wanted to do was move the old board, which was also at an earlier version of phpBB. So I cad to load database, upload the install folder and upgrade the phpBB instance from phpBB 3.2.0 to 3.3.3. I also installed the newest version of American English language pack. I applied logo changes to stylesheet.css and uploaded logo again.
  • My client had used up his file and database quota, causing errors. I tried clearing Trash in file manager but that didn’t work. I suggested working with web host directly, which did work when they upped his quotas.
  • Upgraded a board from phpBB 3.2.0 to 3.3.3. I used the standard prosilver style with custom logo. Bluehost hosting was flaky — could not change the PHP version or access file manager. It took a while to get access to figure out what was needed. Used FTP to do all the upgrade work. I changed reCaptcha from V2 checkbox to V3. I reapplied the logo but suppressed site title and description. Installed Contact Admin extension.
  • In my long term work for a client moving from phpBB 3.0 to 3.3, I finally made some progress on getting a custom OAuth authentication to work. Mainly, I discovered an extension that did something similar and tried to tailor that. The handshake with the OAuth server is not quite there yet, but it’s getting close. Also made some styling changes to reflect changes to the company’s styling made since this effort began nearly a year ago.
  • I upgraded a board from phpBB 3.2.8 to 3.3.3. There was an error after the upgrade clicking on the ACP General tab. Due to a bug in phpBB, phpBB failed to get size of database, due to a hyphen in the database name. This is a known bug so I applied the patch. It should show up as a fix in phpBB 3.3.4. I upgraded the Milk style and its extension. I updated the external links in new windows extension. I asked the client to check if avatar resize and post image upload extensions were still working correctly, as no upgrade was available for either extension. Both still work correctly.