Title: Thread
Last modified: September 29, 2016

---

# Thread

 *  Resolved [jmolenaar](https://wordpress.org/support/users/jmolenaar/)
 * (@jmolenaar)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/thread/)
 * Hello,
 * I use the function below to notify people there is a new thread/topic. Now i 
   want the url to the new topic/thread. Can somebody help me with the code?
 * function after_add($post_id) {
    global $wpdb; $post_title = get_the_title( $post_id);
   $post = $wpdb->get_row($wpdb->prepare(“SELECT text FROM wp_forum_posts WHERE 
   id = %d;”, $post_id)); $to = ‘forum@xxxxx.nl’; $subject = “Nieuw topic geplaats
   op xxxxxx”; $message = “Er is een nieuwe topic geplaatst het xxxxx. <br><br><
   b>Let op!</b> Om op een notificatie te ontvangen wanneer er een reactie is geplaatst
   op het topic dien je je aan te melden voor dit top. Dit doe je door onderaan 
   <i><u>Abonneren op dit onderwerp.</u></i> aan te klikken.<br> <br> “; $headers
   = ‘From: [no-reply@xxx.nl](https://wordpress.org/support/topic/thread/no-reply@xxx.nl?output_format=md)’.“\
   r\n” . ‘BCC: [xxx@xxx.nl](https://wordpress.org/support/topic/thread/xxx@xxx.nl?output_format=md)’.“\
   r\n” . ‘Reply-To: [no-reply@xxx.nl](https://wordpress.org/support/topic/thread/no-reply@xxx.nl?output_format=md)’.“\
   r\n” . ‘Content-Type: text/html; charset=UTF-8’; ‘X-Mailer: PHP/’ . phpversion();
 *  mail($to, $subject, $message, $headers);
 * }

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [Asgaros](https://wordpress.org/support/users/asgaros/)
 * (@asgaros)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/thread/#post-8292220)
 * Hello [@jmolenaar](https://wordpress.org/support/users/jmolenaar/),
 * Basically you can try to get the link for a new topic with this code:
 *     ```
       global $asgarosforum;
       $link = html_entity_decode($asgarosforum->get_link($asgarosforum->current_thread, $asgarosforum->url_thread).'#postid-'.$asgarosforum->current_post);
       ```
   
 * After it you can add it to your message-text.
 *  Thread Starter [jmolenaar](https://wordpress.org/support/users/jmolenaar/)
 * (@jmolenaar)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/thread/#post-8292407)
 * Hello [@asgaros](https://wordpress.org/support/users/asgaros/),
 * Sorry but i am not that technical. You mean the code should be:
 * function after_add($post_id) {
    global $asgarosforum; $link = html_entity_decode(
   $asgarosforum->get_link($asgarosforum->current_thread, $asgarosforum->url_thread).’#
   postid-‘.$asgarosforum->current_post); global $wpdb; $post_title = get_the_title(
   $post_id ); $post = $wpdb->get_row($wpdb->prepare(“SELECT text FROM wp_forum_posts
   WHERE id = %d;”, $post_id)); $to = ‘forum@xxxxx.nl’; $subject = “Nieuw topic 
   geplaats op xxxxxx”; $message = “Er is een nieuwe topic geplaatst het xxxxx. 
   <br><br><b>Let op!</b> Om op een notificatie te ontvangen wanneer er een reactie
   is geplaatst op het topic dien je je aan te melden voor dit top. Dit doe je door
   onderaan <i><u>Abonneren op dit onderwerp.</u></i> aan te klikken.<br> <br> Link
   to the new topic:<br />%s’, ‘asgaros-forum’), esc_html(stripslashes($topic_name)),
   wpautop(stripslashes($topic_text)), $topic_link); “; $headers = ‘From: [no-reply@xxx.nl](https://wordpress.org/support/topic/thread/no-reply@xxx.nl?output_format=md)‘.“\
   r\n” . ‘BCC: [xxx@xxx.nl](https://wordpress.org/support/topic/thread/xxx@xxx.nl?output_format=md)‘.“\
   r\n” . ‘Reply-To: [no-reply@xxx.nl](https://wordpress.org/support/topic/thread/no-reply@xxx.nl?output_format=md)‘.“\
   r\n” . ‘Content-Type: text/html; charset=UTF-8’; ‘X-Mailer: PHP/’ . phpversion();
 * mail($to, $subject, $message, $headers);
 * }
 *  Plugin Author [Asgaros](https://wordpress.org/support/users/asgaros/)
 * (@asgaros)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/thread/#post-8292448)
 * Yes, but for the $message variable try something like this:
 *     ```
       $message = sprintf(__('Er is een nieuwe topic geplaatst het xxxxx. <br><br><b>Let op!</b> Om op een notificatie te ontvangen wanneer er een reactie is
       geplaatst op het topic dien je je aan te melden voor dit top. Dit doe je door onderaan <i><u>Abonneren op dit onderwerp.</u></i> aan te klikken.<br> <br>
       Link to the new topic:<br /><a href="%s">%s</a>', 'asgaros-forum'), $link, $link);
       ```
   
    -  This reply was modified 9 years, 10 months ago by [Asgaros](https://wordpress.org/support/users/asgaros/).
 *  Thread Starter [jmolenaar](https://wordpress.org/support/users/jmolenaar/)
 * (@jmolenaar)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/thread/#post-8292528)
 * That works GREAT!!! THANK U SO MUCH!!!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Thread’ is closed to new replies.

 * ![](https://ps.w.org/asgaros-forum/assets/icon-128x128.png?rev=1546717)
 * [Asgaros Forum](https://wordpress.org/plugins/asgaros-forum/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/asgaros-forum/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/asgaros-forum/)
 * [Active Topics](https://wordpress.org/support/plugin/asgaros-forum/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/asgaros-forum/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/asgaros-forum/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [jmolenaar](https://wordpress.org/support/users/jmolenaar/)
 * Last activity: [9 years, 10 months ago](https://wordpress.org/support/topic/thread/#post-8292528)
 * Status: resolved