| 开发者 | rainafarai |
|---|---|
| 更新时间 | 2026年9月18日 18:17 |
| 捐献地址: | 去捐款 |
| PHP版本: | 7.4 及以上 |
| WordPress版本: | 7.1 |
| 版权: | GPLv2 or later |
| 版权网址: | 版权信息 |
/wp-content/plugins/plugin-name directory, or install the plugin through the WordPress plugins screen directly.When you create a Telegram bot, BotFather generates a unique token for you. BotFather (@botfather) is the official Telegram bot for creating and managing bots — search for it directly inside Telegram. Creating a new bot
There are two quick ways:
Yes. Add @RawDataBot (https://t.me/RawDataBot) to your group or channel (as admin), or simply message it privately. Send any message and it will reply with a full JSON breakdown of the chat, including the exact Chat ID you need.
This usually means no messages have been sent to the bot recently. Try the following:
Yes you can add more than one chattid separated by a comma (,) both in option page and in the shortcode.
Yes! The plugin includes WP-CLI support. Once WP-CLI is installed on your server you can use the wp telegram command. Send a simple message: wp telegram send "Backup complete" Send to a specific chat ID (overrides plugin settings): wp telegram send "Hello" --chatid=123456789 Send the output of a shell command: wp telegram send "$(df -h)" Pipe any command output: df -h | wp telegram send - Send a message with an inline button: wp telegram send "Deploy done" --urlname="Open site" --urllink="https://yoursite.com" Test the connection: wp telegram test Show current plugin configuration: wp telegram status Send a plugin update report to Telegram: wp telegram report_updates Send a WordPress core update report to Telegram: wp telegram report_core Show all available commands: wp telegram help
Yes! This is more reliable than WP-Cron. Add these lines to your crontab (crontab -e): `# Send plugin update report every day at 8am 0 8 * * * cd /var/www/html && wp telegram report_updates --allow-root Send WordPress core update report every day at 9am 0 9 * * * cd /var/www/html && wp telegram report_core --allow-root`
Yes! Starting from version 3.5, this plugin supports the WordPress Abilities API and is compatible with MCP (Model Context Protocol), the open standard that allows AI agents like Claude, ChatGPT, and others to interact with WordPress autonomously.
You need to install two additional free plugins:
Via WordPress Application Passwords — go to Users → Your Profile → Application Passwords, create one, and use it in your MCP client configuration. Your main password is never exposed.
An authorized AI agent can:
You can test everything for free using curl from your terminal. First, make sure the plugin is configured and the built-in "Send Test Message" button works correctly in the plugin settings. Then run these commands in order: Step 1 — Initialize the session and get the Session ID: curl -X POST "https://YOURSITE.com/wp-json/nftb-telegram/mcp" \ -H "Content-Type: application/json" \ -u "ADMIN:APP_PASSWORD" \ -D - \ -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}' Look for the Mcp-Session-Id value in the response headers and copy it. Step 2 — Verify the tool is available: curl -X POST "https://YOURSITE.com/wp-json/nftb-telegram/mcp" \ -H "Content-Type: application/json" \ -H "Mcp-Session-Id: YOUR-SESSION-ID" \ -u "ADMIN:APP_PASSWORD" \ -d '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}' You should see "notification-for-telegram-send-message" in the response. Step 3 — Send a real Telegram message via MCP: curl -X POST "https://YOURSITE.com/wp-json/nftb-telegram/mcp" \ -H "Content-Type: application/json" \ -H "Mcp-Session-Id: YOUR-SESSION-ID" \ -u "ADMIN:APP_PASSWORD" \ -d '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"notification-for-telegram-send-message","arguments":{"message":"🤖 MCP is working!"}}}' If the message arrives in your Telegram chat — everything is working correctly. APP_PASSWORD = a WordPress Application Password (Users → Your Profile → Application Passwords).
This feature is currently experimental. We welcome feedback and bug reports — if you test it, please leave a review or open an issue on the plugin's GitHub page.
Once the required plugins are installed, your MCP endpoint will be available at: https://yoursite.com/wp-json/nftb-telegram/mcp
Yes! You can use the [telegram_mess] shortcode to send Telegram messages directly from your pages, posts or PHP code. Available parameters:
[telegram_mess message="hello world"]
Full example with all parameters:
[telegram_mess message="hello world" chatids="000000,111111" token="123456:ABC-DEF" showsitename="1" showip="1" showcity="1"]
Yes! Use do_shortcode() to call it from your theme or plugin:
<?php $date = date("d-m-Y"); do_shortcode('[telegram_mess message="' . $date . '" chatids="0000000" token="000000000:AAAAAAAAAA" showsitename="1" showip="1" showcity="1"]'); ?>
Yes! The plugin provides 4 filter hooks to customize the WooCommerce order notification message. You can add custom content in 4 positions: Header, Before Items, After Items, and Footer. `<?php add_filter('nftb_order_header_message_hook', 'my_filter_function', 10, 1); add_filter('nftb_order_before_items_hook', 'my_filter_function', 10, 1); add_filter('nftb_order_after_items_hook', 'my_filter_function', 10, 1); add_filter('nftb_order_footer_message_hook', 'my_filter_function', 10, 1); function my_filter_function($order_id) { $order = wc_get_order($order_id); if ($order) { $payment_status = $order->get_status(); $payment_method = $order->get_payment_method(); } return "\r\n\r\n".$payment_method."(".$payment_status.")\r\n"; } ?>`
Yes! Use the nftb_order_product_line_hook filter. You can either add content to the existing line or completely replace it. `<?php add_filter('nftb_order_product_line_hook', 'my_item_line_function', 10, 3); function my_item_line_function($message, $product_id, $item) { // ADD content to the original line $modified_data = $message . "->" . $product_id . "\r\n"; // OR REPLACE the entire line $modified_data = $product_id . "\r\n"; return $modified_data; } ?>`
Yes! The plugin provides 4 filter hooks for login and registration events. `<?php // Triggered on successful user login add_filter('nftb_login_notification', 'custom_message_modifier', 10, 1); // Triggered on new user registration add_filter('nftb_user_registered_notification', 'custom_message_modifier', 10, 1); // Triggered when an existing user fails to login add_filter('nftb_existing_user_fails_login_notification', 'custom_message_modifier', 10, 1); // Triggered when an unknown user fails to login add_filter('nftb_unknown_user_fails_login_notification', 'custom_message_modifier', 10, 1); // Example: append the user registration date to the notification function custom_message_modifier($user_id) { $user_info = get_userdata($user_id); if ($user_info) { $registration_date = $user_info->user_registered; $timestamp = strtotime($registration_date); $formatter = new IntlDateFormatter('en_US', IntlDateFormatter::LONG, IntlDateFormatter::LONG, 'UTC'); $formatter->setPattern('d MMMM y HH:mm:ss'); $message = "\r\n\r\nUser Registration Date: " . $formatter->format($timestamp) . "\r\n\r\n"; } else { $message = "\r\nNo info available for this user.\r\n"; } return $message; } ?>`
Yes. Before hooks were introduced, 3 overridable functions allowed message customization. These are still supported but we encourage migrating to hooks.
<?php function nftb_order_before_items($order_id) { return "ORDER ID: " . $order_id; } ?><?php function nftb_order_after_items($order_id) { $order = wc_get_order($order_id); $data = $order->get_data(); return "Currency: " . $data['currency']; } ?><?php function nftb_order_product_line($product_id, $item) { $product = wc_get_product($product_id); return " | " . $product->get_slug() . " "; } ?>Yes! Notification for Telegram exposes a dedicated action hook so any third-party plugin can send messages without calling internal functions directly.
Basic usage:
do_action( 'nftb_send_message', 'Your message here' );
With an inline button link:
do_action( 'nftb_send_message', 'New order received!', 'View Order', 'https://yoursite.com/order/123' );
With a custom Chat ID:
do_action( 'nftb_send_message', 'Your message', '', '', '123456789' );
Parameters:
$message — (string) required — the text to send$urlname — (string) optional — label of the inline button$urllink — (string) optional — URL of the inline button$chatid — (string) optional — override the default Chat ID from settings
Always check the plugin is active before using the hook:
if ( is_plugin_active( 'notification-for-telegram/index.php' ) ) { do_action( 'nftb_send_message', 'Hello from my plugin!' ); }Yes! If no token is configured, a setup wizard popup appears automatically when you open the plugin settings. It guides you through 3 steps: creating a bot with @BotFather, getting your Chat ID via @chatIDrobot, and sending a test message to verify the connection. You can close the wizard at any time and configure the settings manually instead.
.telegram-notify-page prefix for all styles to prevent conflicts with other plugins and themes (e.g., Elementor).