phpBB trick: automatic all forums subscriptions to all members

>>>phpBB trick: automatic all forums subscriptions to all members

One small forum running on phpBB needed email subscriptions on all forums applied to all members. While it is easy to find a mod adding this feature, it is much more complicated to install a modifications to phpBB rather than vBulletin. Today I’m sharing SQL query accomplishing subscription task on database side.

insert into prefix_forums_watch
select distinct f.forum_id, u.user_id, 0
from prefix_forums f, prefix_users u
where not exists (select 1 from prefix_forums_watch
	where forum_id = f.forum_id
	and user_id = u.user_id) and u.user_type = 0

Instead of prefix correct value set during installation has to be entered. Default is phpbb.

Forum subscriptions are stored on forums_watch table which consists of three fields. Only two are important – forum identifier forum_id and user identifier user_id. Forums and users are stored on forums and users tables respectively.

I found this query at Stack Overflow and made one modification – added condition user_type = 0 which enables subscriptions only for regular registered users. Search bots are stored on the same table but there is no need to enable subscriptions for them.

2016-10-24T10:57:02+00:002011-04-14|Programming|1 Comment

About the Author:

Gytis Repečka is System analyst with passion to open source, electronics & cars, spreading bits about tech, music and privacy.

One Comment

  1. Dennis 2013-05-26 at 23:52 - Reply

    Great work here. This saved me a ton of time. I was able to achieve the desired results for my members in seconds. I used this to subscribe the moderators for the moderators then removed the unneeded tables. A little extra work.

    How would I modify this so that I can subscribe all users to a singe topic/post.

Leave A Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.