Please or Register to create posts and topics.

how to correctly get data about Username ,topic name ,link url

how to correctly get data about
User: ??
Topic: ??
Link: ??

telegram message:

Forum notification: New topic
User:
Topic:
Link:
my code in functions.php:
add_action('asgarosforum_after_add_topic_submit', 'send_to_telegram_new_topic');
/ Sending a notification for a new topic
function send_to_telegram_new_topic($topic_id) {

// Get topic data
 $topic_data = get_post($topic_id);

 // Bot token Telegram
 $telegram_token = ”; 
  
 // Telegram chat ID where we send
 $chat_id = ”;

 // Formае the text of the message
 $message = “Forum notification: New topic\n”;
 $message .= “User: ” . get_the_author_meta($topic_data->post_author, ‘display_name’) . “\n”;
 $message .= “Topic: ” . $topic_data->post_title . “\n”;
 $message .= “Link: ” . get_permalink($topic_id);

 // Sending a send request to Telegram
 wp_remote_get(“https://api.telegram.org/bot$telegram_token/sendMessage?chat_id=$chat_id&text=” . urlencode($message));

}

in telegram im receive this:

Forum notification: New topic
User:
Topic:
Link:

without data(

add_action(‘asgarosforum_after_add_topic_submit’, ‘send_to_telegram_new_topic’);
add_action(‘asgarosforum_after_add_post’, ‘send_telegram_notification_on_new_reply’);

function send_to_telegram_new_topic($forum_id, $topic_id, $post_id) {
send_telegram_notification(‘Нова тема’, $forum_id, $topic_id, $post_id);
}

function send_telegram_notification_on_new_reply($forum_id, $topic_id, $post_id) {
send_telegram_notification(‘Нова відповідь’, $forum_id, $topic_id, $post_id);
}

function send_telegram_notification($notification_type, $forum_id, $topic_id, $post_id) {
$bot_token = ”;
$chat_id = ”;

// Get forum, topic, and post information
$forum_name = get_term($forum_id)->name;
$topic_title = get_the_title($topic_id);
$post_url = get_permalink($post_id);

$message = “Сповіщення форуму: $notification_type\n”;
$message .= “Тема: $topic_title в форумі $forum_name\n”;

if ($notification_type == ‘Нова тема’) {
$topic_url = get_term_link($topic_id, ‘topic’);
$message .= “Посилання на тему: $topic_url”;
} elseif ($notification_type == ‘Нова відповідь’) {
$message .= “Посилання на відповідь: $post_url”;
}

wp_remote_get(“https://api.telegram.org/bot$bot_token/sendMessage?chat_id=$chat_id&text=” . urlencode($message));
}

please help not work!