The Subscriber Manager for Telegram plugin includes hooks and filters you can use to modify the behavior of the plugin or trigger additional functionality. Note, these are meant for experienced WordPress developers familiar with implementing custom code. Improperly implemented code can break your site.
Actions
wc_wctlgm_invite_links_generated
Fires after Telegram invite links are generated and stored for an order. This action is what powers the WooCommerce Webhook integration. Use it to trigger custom logic whenever a customer receives invite links.
Since: 1.5.0
Parameters:
$order_id(int) — The WooCommerce order ID.$channels(array) — Array of channel data, each containingchannel_id,name, andinvite_link.
add_action( 'wc_wctlgm_invite_links_generated', function( $order_id, $channels ) {
// Example: Log the invite links to a custom table
foreach ( $channels as $channel ) {
error_log( sprintf(
'Order %d: Invite link for %s: %s',
$order_id,
$channel['name'],
$channel['invite_link']
) );
}
}, 10, 2 );
wctlgm_load_extensions
Fires during plugin initialization, before subscription handlers are resolved. Use this hook to register custom subscription backends via the handler factory.
Since: 1.6.0
Parameters: None.
add_action( 'wctlgm_load_extensions', function() {
WC_Telegram_Subscriptions_Handler_Factory::register_handler(
'My_Subscription_Plugin_Class', // Class name to detect
'My_Custom_Handler_Class' // Handler class to instantiate
);
} );
The custom handler class must implement WC_Telegram_Subscriptions_Interface. See the plugin source code for the full interface contract.
Filters
wctlgm_modify_telegram_user_id_before_removal
This filter hook allows you to modify the user ID set for removal from a private Telegram group or channel. The typical use case is for preventing certain users from being removed from the site such as admins, usually due to expiring test orders.
Since: 1.4.0
add_filter( 'wctlgm_modify_telegram_user_id_before_removal', function( $telegram_user_id ) {
$my_telegram_user_id = '123456789';
$telegram_user_id = (string) $telegram_user_id;
$my_telegram_user_id = (string) $my_telegram_user_id;
// Check if the current user ID is yours and if so, return an empty value
if ( $telegram_user_id === $my_telegram_user_id ) {
return ''; // Return an empty string to prevent removal
}
// Return the original user ID if not yours
return $telegram_user_id;
}, 10, 1 );
wctlgm_webhook_payload
Filters the WooCommerce webhook payload before it is delivered. Fires only for the “Telegram Invite Links Generated” webhook topic. See the WooCommerce Webhook Integration article for the full payload schema.
Since: 1.5.0
Parameters:
$payload(array) — The payload array.$order(WC_Order) — The WooCommerce order object.$channels(array) — The channels array.$webhook_id(int) — The WooCommerce webhook ID.
add_filter( 'wctlgm_webhook_payload', function( $payload, $order, $channels, $webhook_id ) {
// Add a custom field to the outbound webhook payload
$payload['membership_level'] = $order->get_meta( '_membership_level' );
return $payload;
}, 10, 4 );
wctlgm_activation_info_output
Filters the HTML output shown to the customer when an activation code is displayed on the thank-you page and in order detail emails. Use this to customize how activation instructions appear.
Since: 1.5.0
Parameters:
$output(string) — The HTML string to display.$activation_code(string) — The raw 8-character activation code.
add_filter( 'wctlgm_activation_info_output', function( $output, $activation_code ) {
// Add a custom message below the activation info
$output .= '<p class="my-custom-note">Need help? Contact support.</p>';
return $output;
}, 10, 2 );