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