Auto Subscribe to forum

Looking for a MOD? Have a MOD request? Post here for help. (Note: This forum is community supported; phpBB does not have official MOD authors)
Get Involved
pdgfigueira
Registered User
Posts: 13
Joined: Thu Aug 07, 2008 3:28 pm

Re: Auto Subscribe to forum

Post by pdgfigueira »

Hi. I've found out that the column notify in the phpbb_forums_watched should be set to 0 (zero) in order to an email be sent (thanks to this support request). So the code should be:

Code: Select all

$sql = 'INSERT INTO phpbb_forums_watch SELECT frm.forum_id, usr.user_id, 0 FROM phpbb_users usr, phpbb_forums frm WHERE (usr.user_id > 52 OR usr.user_id = 2) AND (frm.forum_id, usr.user_id) NOT IN   (SELECT frm_wtch.forum_id, frm_wtch.user_id FROM phpbb_forums_watch frm_wtch);';
$db->sql_query($sql);
$sql = 'INSERT INTO phpbb_topics_watch SELECT tpc.topic_id, usr.user_id, 0 FROM phpbb_users usr, phpbb_topics tpc WHERE (usr.user_id > 52 OR usr.user_id = 2) AND (tpc.topic_id, usr.user_id) NOT IN (SELECT tpc_wtch.topic_id, tpc_wtch.user_id FROM phpbb_topics_watch tpc_wtch);';
$db->sql_query($sql);
Hope this modification will work for you too. Please also beware that this change can stress a busy forum.

Best regards
PFigueira
User avatar
Typo
Former Team Member
Posts: 404
Joined: Tue Dec 30, 2008 6:12 am
Location: USA
Name: Jeremy Lorenzo
Contact:

Re: Auto Subscribe to forum

Post by Typo »

For anyone reading this thread that did not notice this mod....

Board Watch By asinshesq
Modification description: This mod gives users a 'board watch' option to receive notifications for posts made anywhere on the site (analogous to forum watch but for the entire board).

Each user can choose between two ways for board watch to work:

(1) Send notification of the first post since the user's last visit and send no further notifications until the user revisits the site (analogous to the way forum watch and topic watch work)

(2) Send notifications of all posts.

In addition, each user can choose whether forum watch and topic watch work in the normal phpbb3 way (analogous to (1) above) or instead send notifications of all posts or replies in the subscribed forums or topics. The ability to choose between these two ways of working for boardwatch. forum watch and topic watch can be turned off in the acp.

This mod also slightly changes the wording of the regular phpbb3 notifications to let recipients know how to change their notification settings, and it changes the post links in those notifications so that they lead to the earliest unread post in the topic in question (which I think is a more logical destination than the most recent post in the topic).
I use this but personally I used the instructions in the thread to disable it by default and then the users can enable it if they wish in the ucp. When I installed it, it was notifying by default for newly registered users and some people complained and had to be shown how to turn it off in the ucp.

Hope this helps someone.

Typo
jrmiller
Registered User
Posts: 6
Joined: Wed Feb 25, 2009 3:17 am

Re: Auto Subscribe to forum

Post by jrmiller »

ejenner wrote:I couldn't find any pre-built modifications for making this work. But I have successfully identified the changes that need to be made if you want your users subscribed to a forum without having to individually open each user account.


What I did was as follows:

1. Open my SQL editor so you can see the tables in the forum database

2. Locate table named 'phpbb_users'
I like ejenner's workaround but I am such a newbie I don't know how to locate the files he wants me to open in my SQL editor?! :oops: Can someone point me to where I can find these files in the directory structure?
Thanks!!!
pdgfigueira
Registered User
Posts: 13
Joined: Thu Aug 07, 2008 3:28 pm

Re: Auto Subscribe to forum

Post by pdgfigueira »

jrmiller wrote: I like ejenner's workaround but I am such a newbie I don't know how to locate the files he wants me to open in my SQL editor?! :oops: Can someone point me to where I can find these files in the directory structure?
Thanks!!!
You don't "open files" in your SQL editor, you connect to your database.
smoore33
Registered User
Posts: 11
Joined: Sun Jun 07, 2009 2:29 am
Location: Sonoma County, California

Re: Auto Subscribe to forum

Post by smoore33 »

I also use phpBB with a group of non-technical users (a music ensemble) who don' t use the site, largely because they don't "get" that they have to manually subscribe to every forum. I believe that the checked box in front of "Subscribe forum" also confuses people into thinking that they are subscribed, when they are not (a checked box usually means "this has already been done"). This is turning out to be a fatal limitation for our use of the software. I hope these two items can be improved. Thanks.
TanGU
Registered User
Posts: 12
Joined: Thu Sep 10, 2009 5:30 pm

Re: Auto Subscribe to forum

Post by TanGU »

pdgfigueira wrote:Hi. I've found out that the column notify in the phpbb_forums_watched should be set to 0 (zero) in order to an email be sent (thanks to this support request). So the code should be:

Hope this modification will work for you too. Please also beware that this change can stress a busy forum.

Best regards
PFigueira
Yes thanks a lot, it help a lot.

But what happen if certain forums are only seen by a certain group of users. Will ALL users will be notified ? I think so...

So i should change the INSERT right ?
TanGU
Registered User
Posts: 12
Joined: Thu Sep 10, 2009 5:30 pm

Re: Auto Subscribe to forum

Post by TanGU »

By the way, if the user receive the notification topic on a forum, and he doesn't visit the forum the notify_status will stay at "1" until the next visit. So to permit a notification on each topic, you can set a cronjob to do this, everynight, or every hour if you want :

UPDATE `phpbb_forums_watch` SET `phpbb_forums_watch`.`notify_status`= 0 WHERE `phpbb_forums_watch`.`notify_status` = 1
TanGU
Registered User
Posts: 12
Joined: Thu Sep 10, 2009 5:30 pm

Re: Auto Subscribe to forum

Post by TanGU »

ejenner wrote:
What would be really neat is if someone with SQL scripting knowledge were to create a little batch file that gets the user number from 'phpbb_users' and adds the line to 'phpbb_forums_watch' - then this could be scheduled for a couple of times a day or once a week or whenever...
Like i said in my previous post, i did that, in php script, and it run fine on a cronjob over cpanel.

BUT

The problem is, that every user get notified once there is a single reply to each post ! Witch is pretty annoying, even post that user didn't reply, they will receive a notification email of it.

So i have a lot of complain. People only wants to be notified on new topic. Then if they reply on that topic, they should receive others notification...

Is there a solution for that ?

thanks!
msharma
Registered User
Posts: 1
Joined: Thu May 27, 2010 7:49 am

Re: Auto Subscribe to forum

Post by msharma »

Hello all,
I have got this small piece of code that I would like to share with all of you. I manage a small forum that has limited number of users. What I required was to a functionality in the forum so that all users get notification to all the new-topics in the forum. So I created this small little script that can be added to the includes/functions_user.php file in the function user_add.

You have to follow following steps for this:

1. Log in to administrator area go to administrator >> General >> post settings .
2. Set Allow subscribing to topics, Allow subscribing to forums to yes.
3. Go to includes/functions_user.php find function user_add
4. Find $user_id = $db->sql_nextid(); and paste the code after this line.

The code is :

Code: Select all

/*------ subscribe every new user to all forums start---------*/
	$sql = 'SELECT forum_id from '.FORUMS_TABLE;
	$result=$db->sql_query($sql);
	while ($row = $db->sql_fetchrow($result)){
		$arrForum[]=(int)$row['forum_id'];
	}
	foreach($arrForum as $forumId){
		$sql = 'INSERT INTO '.FORUMS_WATCH_TABLE.' (`forum_id`,`user_id`,`notify_status`) VALUES ('.$forumId.','.$user_id.',0)';
		$db->sql_query($sql);
	}
	/*------ subscribe every new user to all forums end ---------*/
	
Save the file. Now Every new user will be automatically subscribed to all the forums and will get notifications for all the topics.

Hope you all like it. :)

Cheers,
Manish
Andy-G
Registered User
Posts: 1
Joined: Mon Sep 27, 2010 3:23 pm

Re: Auto Subscribe to forum

Post by Andy-G »

Manish,

Thanks for posting your solution to the problem.

Can your code be modified to autosubscribe newly registered users to a SINGLE forum instead of all forums?

Thanks,

Andy.
tomvdp
Registered User
Posts: 1
Joined: Mon Mar 02, 2009 11:14 am

Re: Auto Subscribe to forum

Post by tomvdp »

Here is the sql I used to subsribe all my users to all the forums:

Code: Select all

insert into forums_watch (user_id, forum_id, notify_status)
SELECT u.user_id, f.forum_id, 0 notify_status
FROM users u, forums f
where u.user_type=0
and not exists (select 1 from forums_watch fw where fw.user_id=u.user_id and fw.forum_id=f.forum_id)
Note that you may have to add a prefix to the table names per your setup. (forums_watch, users, forums)
User avatar
XelNagah
Registered User
Posts: 14
Joined: Mon Jul 12, 2010 6:40 am

Re: Auto Subscribe to forum

Post by XelNagah »

Hi guys,

I have been working on a MOD that does what is requested here.

Its is still rudimentary about the operation since I assign the forums manually by way of SQL queries on a table, but it works and is deployed on our forum.

I asked the MOD community to continue the project to make of this an actual MOD.

Since it already works, maybe you find this useful, so here's the topic:

http://www.phpbb.com/community/viewtopi ... &t=2130798

Xel.-
rkleivel
Registered User
Posts: 1
Joined: Wed Oct 10, 2012 8:50 pm

Re: Auto Subscribe to forum

Post by rkleivel »

I needed to autosubscribe new users to a certain forum. Performed this with a trigger on the users-table, so that when a new user is inserted there is automatically created an entry in the forums_watch table which adds a watch for the new user to the forum in question (in my case forum_id 7)

Code: Select all

CREATE TRIGGER `add_watch` AFTER INSERT ON `phpbb_users`
 FOR EACH ROW INSERT INTO phpbb_forums_watch SET user_id = NEW.user_id, forum_id = 7, notify_status = 0
User avatar
robra
Registered User
Posts: 147
Joined: Thu Dec 09, 2010 2:09 am
Location: Brazil

Re: Auto Subscribe to forum

Post by robra »

I don't know if will resolve but look this: [Request] Subscribe to Group's Forums - Needs completion.

[].
ZillaConsulting
Registered User
Posts: 2
Joined: Fri Nov 30, 2012 6:26 am

Re: Auto Subscribe to forum

Post by ZillaConsulting »

rkleivel wrote:I needed to autosubscribe new users to a certain forum. Performed this with a trigger on the users-table, so that when a new user is inserted there is automatically created an entry in the forums_watch table which adds a watch for the new user to the forum in question (in my case forum_id 7)

Code: Select all

CREATE TRIGGER `add_watch` AFTER INSERT ON `phpbb_users`
 FOR EACH ROW INSERT INTO phpbb_forums_watch SET user_id = NEW.user_id, forum_id = 7, notify_status = 0
This answer partly meets my needs going forwards, but what would meet my needs completely is the ability to include multiple insert statements in the trigger as I would like to autosubscribe new users to multiple forums. Any suggestions on the syntax to use to achieve this?
Locked

Return to “[3.0.x] MOD Requests”