SubscriptCatForum – User Subscription to Forum Updates

The plugin for Cotonti designed to simplify tracking forum activity. Users do not need to regularly check the sections they are interested in: the system automatically sends notifications about new events.

SubscriptCatForum Plugin for Cotonti CMF

User subscription to forum category updates

1. Functional Overview and Purpose

SubscriptCatForum is a plugin for Cotonti CMF that implements a system allowing users to subscribe to forum categories. After subscribing, the user receives email notifications when new events appear in the selected sections.

The main purpose of the plugin is to simplify tracking activity on the forum. Users do not need to regularly check the sections they are interested in: the system automatically sends notifications about new events.

Main Features

Subscription to forum categories

The user can select one or several forum categories and subscribe to their updates. Subscription management is performed through a separate plugin page.

After subscribing, the user will receive notifications about all new events in the selected sections.

Email notifications

When new events appear in a category, the plugin sends an email notification to subscribers. The message contains:

  • topic title
  • section title
  • name of the message author
  • text of the latest message (without HTML)
  • link to the topic
  • link to the specific post

Tracked events

The plugin reacts to forum events through the Cotonti hook system. Notifications are sent for the following actions:

  1. creation of a new topic in a category
  2. creation of a new post in a topic
  3. editing a message
  4. moving a topic between categories (handled in the notification logic)

User subscription management

The user can:

  • subscribe to categories
  • modify the list of subscriptions
  • completely remove subscriptions

This is done through a separate plugin page available via the user account menu.

Administrative subscription management

The site administrator can:

  • view subscribers of each category
  • add a user to a subscription
  • remove a user from a subscription

The administrative interface displays a list of forum categories and the users subscribed to them.

Advantages of using

  1. The user follows only the sections they are interested in.
  2. There is no need to subscribe to each topic individually.
  3. The chance of missing new discussions is reduced.
  4. The administrator can centrally manage subscriptions.

Current limitations

At the moment of implementation the plugin has the following limitations:

  • notifications are sent immediately when an event occurs (without cron)
  • pagination is not implemented
  • debug logging is enabled

The plugin is intended for use on small Cotonti forums.

Requirements

The plugin was tested in the following configuration:

  • Cotonti CMF (latest version from GitHub as of 25-02-2025)
  • PHP 8.4
  • MySQL 8.4

2. Technical part (plugin operation)

The plugin uses the Cotonti hook system, which allows it to react to forum events and send notifications.

Plugin architecture

Main components:

  • subscription table
  • forum event hooks
  • standalone subscription management page
  • administrative interface
  • subscription management functions

Subscription table

The plugin creates a separate table:

CREATE TABLE IF NOT EXISTS `cot_subscriptcatforum` (
`id` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
`user_id` INT UNSIGNED NOT NULL,
`cat_forum_subs` text NOT NULL,
`created_at` INT UNSIGNED NOT NULL DEFAULT 0
);

Fields:

fielddescription
idunique record identifier
user_iduser ID
cat_forum_subsforum category code
created_atsubscription creation time

Forum hooks

The plugin reacts to several forum events.

1. New post

Hook:

  Hooks=forums.posts.newpost.done  

File:

  subscriptcatforum.forums.posts.newpost.done.php  

Main actions:

  1. determine the topic ID and category code
  2. retrieve the latest post
  3. find subscribers of the category
  4. compose the email
  5. send notifications

Retrieving subscribers:

$subscribers = $db->query("
    SELECT u.user_email, u.user_id 
    FROM $db_subscriptcatforum s
    JOIN $db_users u ON s.user_id = u.user_id
    WHERE s.cat_forum_subs = ? 
    AND u.user_id != ?", [$section_code, $post_author_id])->fetchAll();

The post author is excluded from the recipients list.


2. Creating a new topic

Hook:

  Hooks=forums.newtopic.newtopic.done  

File:

  subscriptcatforum.forums.newtopic.newtopic.done.php  

Algorithm:

  1. determine the topic ID
  2. retrieve the topic title and category
  3. obtain the first post data
  4. compose the email
  5. send notifications to category subscribers

3. Editing a post

Hook:

  Hooks=forums.editpost.update.done  

File:

  subscriptcatforum.forums.editpost.update.done.php  

This handler:

  • receives the category
  • finds subscribers
  • retrieves the updated post
  • sends an edit notification

Link generation

Links to the topic and post are generated using standard Cotonti functions:

$topic_url = cot_url('forums', 'm=posts&q=' . $topic_id);
$post_url = cot_url('forums', "m=posts&id=" . $post_id . "&n=last", "#bottom");

Email sending

The built-in Cotonti function is used:

  cot_mail($user_email, $subject, $message);   

Logging

File logging is used for debugging:

function log_to_file_newpostdone($message) {
$logfile = __DIR__ . '/subscription_debug.log';
$date = date('Y-m-d H:i:s');
file_put_contents($logfile, "[$date] $message\n", FILE_APPEND);
}

The log records:

  • handler start
  • request parameters
  • found subscribers
  • sent emails

Subscription management functions

File:

  subscriptcatforum.functions.php  

Main functions:

Subscription check

function check_existing_subscription($user_id, $forum_id) {
return $db->query("SELECT COUNT(*) FROM $db_subscriptcatforum WHERE user_id = ? AND cat_forum_subs = ?", [$user_id, $forum_id])->fetchColumn() > 0;
}

 

User subscription

function subscribe_user($user_id, $forum_id) {
$db->query("INSERT INTO $db_subscriptcatforum (user_id, cat_forum_subs, created_at) VALUES (?, ?, ?)", [$user_id, $forum_id, time()]);
}

 

User unsubscription

function unsubscribe_user($user_id, $forum_id) {
$db->query("DELETE FROM $db_subscriptcatforum WHERE user_id = ? AND cat_forum_subs = ?", [$user_id, $forum_id]);
}

3. Installation, configuration and operation

Plugin installation

  1. Copy the plugin folder
  subscriptcatforum  

to the directory

  /plugins/  
  1. Open the Cotonti administrator panel.
  2. Find the SubscriptCatForum plugin.
  3. Install it.

During installation the table is automatically created:

  cot_subscriptcatforum   


Adding a link to the user menu

To access the subscription management page you need to add a link to the theme template.

Example fragment:

<!-- IF {PHP|cot_plugins_active('subscriptcatforum')} -->
<li><a href="{PHP|cot_url('subscriptcatforum')}">{PHP.L.subscriptcatforum_title_link}</a></li>
<!-- ENDIF -->

  

The link is usually placed in the user account menu.


Subscription management page

The plugin page displays:

  • list of forum categories
  • category hierarchy
  • selection checkboxes

Example HTML structure:

<input type="checkbox" 
      class="form-check-input"
      name="selected_categories[]" 
      value="{CATEGORY_CODE}"
      {IS_SELECTED}>

After submitting the form:

  1. old user subscriptions are removed
  2. selected categories are written to the table
$db->query("DELETE FROM $db_subscriptcatforum WHERE user_id = ?", [$usr['id']]);

Then new records are added.


Subscription administration

The administrator can manage subscriptions via the tool:

  admin → tools → subscriptcatforum  

The interface displays:

  • forum categories
  • list of subscribers
  • form for adding a user

Adding a user:

$db->insert($db_x . "subscriptcatforum", [
   'user_id' => $user_id,
   'cat_forum_subs' => $category_id,
   'created_at' => time()
]);

Removing a user:

$db->delete($db_x . "subscriptcatforum", "user_id = ? AND cat_forum_subs = ?", [$user_id, $category_id]);

Operation

The plugin starts working immediately after installation.

Notifications are automatically sent when:

  • a topic is created
  • a post is published
  • a message is edited

All events are recorded in logs, which allows diagnostics to be performed.

Plugin support topic, questions, discussions and suggestions

Download the plugin https://github.com/webitproff/cot-subscriptcatforum

Buy SubscriptCatForum – User Subscription to Forum Updates at low prices. Online store offers to order SubscriptCatForum – User Subscription to Forum Updates, view full description, detailed specifications, product photos and current prices with discounts


Rating based on reviews:
Stars received: 0
Total reviews: 0
Average rating: 0
5 minutes read

Reviews to products

No reviews yet


Add to Cart

Product has no downloadable file

 

Category Extentions
Notifications, email and SMS campaigns, Subscriptions and newsletters
Availability
Free

Content author

webitproff

Offline

webitproff

Last logged: 2026-09-03 18:32

About me briefly
Support and development of web projects on the CMF Cotonti: private messengers via the website, open and closed small social networks, trading platforms and marketplaces, freelance and services exchange portal, catalogs of goods from wholesale suppliers, dropshipping platforms, online stores, and much more.
View developments and download
Public portfolio of my works and developments
Telegram for messages
@webitproff
Telegram channel
@s/aBuyFILE

Market PRO Storefront

CMS, Script and Engine - website of online storefront, online store of info products and digital goods. Different prices in different currencies per product. Online cryptocurrency payment for goods and services.