• Resolved jmolenaar

    (@jmolenaar)


    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’ . “\r\n” .
    ‘BCC: xxx@xxx.nl’ . “\r\n” .
    ‘Reply-To: no-reply@xxx.nl’ . “\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

    (@asgaros)

    Hello @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

    (@jmolenaar)

    Hello @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‘ . “\r\n” .
    ‘BCC: xxx@xxx.nl‘ . “\r\n” .
    ‘Reply-To: no-reply@xxx.nl‘ . “\r\n” .
    ‘Content-Type: text/html; charset=UTF-8’;
    ‘X-Mailer: PHP/’ . phpversion();

    mail($to, $subject, $message, $headers);

    }

    Plugin Author Asgaros

    (@asgaros)

    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, 3 months ago by Asgaros.
    Thread Starter jmolenaar

    (@jmolenaar)

    That works GREAT!!! THANK U SO MUCH!!!

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

The topic ‘Thread’ is closed to new replies.