Notification for Telegram
NOTIFICATION FOR TELEGRAM WORDPRESS PLUGIN
Receive Telegram messages notification when: Send Telegram messages notification: * When receive a new order in Woocommerce. * When a Woocommerce order change status. * New field in Woocommerce checkout page let customers add the own telegram nickname * Low Stock Product notifications when a product is low stock conditions. * Shows Telegram Nick link in admin order details page when present * When receive new forms (supports Elementor Pro Form, WPForm , CF7 and Ninjaform) * When new user subscribes or unsubscribes to mailchimp. MC4WP integration * When new user registers. * When users login or fail login. * When someone adds or remove a product in the Woocommerce cart. * When a new Pending posts is received. (works with any post type) * Say function to speak to make the bot say Something to the people * Cron job detect and notify when Plugins & Core need to update. * Send custom message with Shortcode anywhere in your WP. * Should Work on Multisite If you have time, remember to Rate this plugin on wordpress rep !!! https://it.wordpress.org/plugins/notification-for-telegram/
WOOCOMERCE FILTER HOOKS
We have created 4 filter hooks for WooCommerce order notification message. 4 new positions: Message Header, Message Footer, before Items, and after Items. And we have created a filter through which you can add custom code to product rows, and if you want, you can replace and customize the entire row. :
4 new Positions and code axample
( example echos payment_status in the 4 positions)
`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) {
// Get order details
$order_data = $order->get_data();
// Extract specific order information
$payment_status = $order->get_status();
$payment_method = $order->get_payment_method();
}
return “\r\n\r\n”.$payment_method.”(“.$payment_status.”)\r\n” ;
}
?>`
Product rows Filter with 2 different behaviors ADD or REPLACE LINE
`add_filter(‘nftb_order_product_line_hook‘, ‘my_item_line_function’, 10, 3);
function my_item_line_function($message ,$product_id, $item) {
// ADD SOME CODE $product_id TO ORIGINAL row $message.
$modified_data = $message. “->”.$product_id. “\r\n”;
// REPLACE Product ITEM LINE CODE WITH YOUR CODE without concatenate $message.
$modified_data = $product_id. “\r\n”;
return $modified_data;
}
?>`
USER LOGIN HOOKS
`//Filter to add code on user login notification message
add_filter(‘nftb_login_notification‘, ‘custom_message_modifier’, 10, 1);
//Filter to add code on user registration notification message
add_filter(‘nftb_user_registered_notification‘, ‘custom_message_modifier’, 10, 1);
//Filter to add code when existing user fails login notification message
add_filter(‘nftb_existing_user_fails_login_notification‘, ‘custom_message_modifier’, 10, 1);
//Filter to add code when unknown user fails login notification message
add_filter(‘nftb_unknown_user_fails_login_notification‘, ‘custom_message_modifier’, 10, 1);
// in this example we add User registration date to notification message
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);
$locale = ‘it_IT’; // Italian locale
$formatter = new IntlDateFormatter($locale, IntlDateFormatter::LONG, IntlDateFormatter::LONG, ‘UTC’);
$formatter->setPattern(‘d MMMM y HH:mm:ss’);
$formatted_date = $formatter->format($timestamp);
$message = “\r\n\r\nUser gistration Date: ” . $formatted_date.”\r\n\r\n”;
} else {
$message = “\r\n No info about user ! \r\n ” ;
}
return $message;
}
?>`