XF 2.0 Query to make a specific User Group watch specific forum

Mr Lucky

Well-known member
Is it possible to run a query to make one specific User Group watch a specific forum or a set of forums?

Thanks
 
This will probably do it (usual rules about running on a test install, backups etc. apply):
SQL:
INSERT INTO xf_forum_watch
(user_id, node_id, notify_on, send_alert, send_email)
SELECT user_id, 123, 'thread', 1, 0
FROM xf_user
WHERE FIND_IN_SET(4, secondary_group_ids)
You'd need to run it for each node_id and user group ID. 123 represents the node_id and 4 represents the user group. This will only check the usergroup against the secondary_group_ids field.
 
Thanks first test didn't work though.

using forum id 33 and secondary user group id 18

SQL:
INSERT INTO xf_forum_watch
(user_id, node_id, notify_on, send_alert, send_email)
SELECT user_id, 33, 'thread', 1, 0
FROM xf_user
WHERE FIND_IN_SET(18, secondary_group_ids)

SQL:
Error

MySQL said: Documentation
#1062 - Duplicate entry '4650-33' for key 'PRIMARY'
 
@Chris D & @Brogan I would like to ask a question about watched threads and forums. Is there maybe a query I can run to stop watching threads and forums for banned users? Otherwise, is there no other way to do this, out of Admin Control Panel?
 
@Chris D & @Brogan I would like to ask a question about watched threads and forums. Is there maybe a query I can run to stop watching threads and forums for banned users? Otherwise, is there no other way to do this, out of Admin Control Panel?

I can't answer that, but I'm sure they should not be getting notications anyway. I vaguely remember a thread about this a few years ago...
 
Well — thank you for your answer, which I think was important and valuable. But you know, this is the matter of tastes and colours.

Anyway, I found a solution but I didn't try it yet.

SQL:
SELECT * FROM xf_thread_watch
LEFT JOIN xf_user_ban ban ON (ban.user_id = xf_thread_watch.user_id)
WHERE ban.user_id;

This will show you the result of banned users who are watching threads.

SQL:
SELECT * FROM xf_forum_watch
LEFT JOIN xf_user_ban ban ON (ban.user_id = xf_forum_watch.user_id)
WHERE ban.user_id;

And this will show you the result of banned users who are watching forums.

However, you are free to do anything you like. So this is often a matter of taste as I said.

Greetings!
 
Last edited:
Just means that one user is already watching that forum. Try changing INSERT INTO to INSERT IGNORE INTO.
Strange, I just reran this query as there are users who registered since the last timeand am getting the duplicate entry error even with INSERT IGNORE INTO. instead of INSERT INTO
 
Back
Top Bottom