bbPress Plugin Browser »

Subscribe To Topic (0.0.6)

Download

Version: 0.0.6

Last Updated: 2009-6-7

Requires bbPress Version: 0.9 or higher

Compatible up to: 0.9

Author Homepage »

Plugin Homepage »

Donate to this plugin »

Average Rating

5 stars
4 stars
3 stars
2 stars
1 star
(7)

Your Rating

Author: _ck_


  1. @naviathan

    I think the problem you encountered is ALMOST EXACTLY the same as I experienced. This is the solution I applied to get the code working - please bear in mind, I was using two separate hosts, however you can use my solution as a guide.

    First of all, ensure your subscribe table exists on the same installation as your forum.

    Find function "stt_notify", I've modified it to be like

    function stt_notify($post_id = 0) {
    //remove_action('bb_new_post', 'stt_notify'); // bbpress bug, fires multiple times?
    global $bbdb, $topic_id, $bb_current_user, $subscribe_to_topic; $time=time()-60;
    $topic=get_topic($topic_id); if (empty($post_id) || empty($bb_current_user->ID) || ($topic->topic_posts<2)) {return;}
    $query = "SELECT username, useremail as user_email FROM subscribe_to_topic WHERE topic = ".$topic_id." AND type = 2 AND time < ".$time." AND post > last";

    $emails=$bbdb->get_results($query); if (empty($emails)) {return;}

    $topic_link=get_post_link($post_id);
    $unsubscribe=add_query_arg( 'unsubscribe', $topic_id, $topic_link);
    $from=bb_get_option('from_email'); if (empty($from)) {$from=bb_get_option('admin_email');}
    $from_email='From: ' .$from;
    $user_name=get_user_name($bb_current_user->ID);
    $subject="[".bb_get_option('name') . ']' ." ". __('new post notification');
    $message = __("There is a new post on [%1\$s] \n\nReply by: %2\$s \n%3\$s \n\n\nUnsubscribe: \n%4\$s \n");

    foreach ($emails as $email){
    mail($email->user_email, $subject, sprintf($message, $topic->topic_title, $user_name, $topic_link, $unsubscribe), $from_email);

    $ids[$email->user_id]=$email->user_id;
    // print "$email->user_email
    \n";
    }
    if (!empty($ids)) {
    $ids=implode(',',$ids); $time=time();
    $bbdb->query("UPDATE ".$subscribe_to_topic['db']." SET last=$post_id,time=$time WHERE topic=$topic_id AND user IN ($ids)");
    }
    }

    find function "stt_change_level", I've modified it so it like:

    function stt_change_level($user_id=0,$topic_id=0,$level=0, $user_info = "") {
    global $bbdb, $subscribe_to_topic, $bb_current_user;
    // print("<hr>

    ");
        // print_r($user_info);
        // print("
    <hr>");
    if (empty($user_id) || empty($topic_id)) {return;}
    if ($level===0) {return $bbdb->query("DELETE FROM ".$subscribe_to_topic['db']." WHERE user=$user_id AND topic=$topic_id LIMIT 1");}
    $topic=get_topic($topic_id);
    $query="INSERT INTO ".$subscribe_to_topic['db']." (user, topic, post, type, username, useremail)
    VALUES ('".$user_id."', '".$topic_id."', '".$topic->topic_last_post_id."', '".$level."', '".$bb_current_user->user_login."', '".$bb_current_user->user_email."')
    ON DUPLICATE KEY UPDATE post = VALUES( post), type = VALUES( type)";
    return $bbdb->query($query);
    }

    if you're still battling, email me: trippygrape [AT] gmail dot com and i'll send you my modified code which you can work on as a guide

    cheers,
    John

    Posted: 1 year ago #
  2. Thanks. I could use part of the code.

    Posted: 11 months ago #

RSS feed for this topic

Add a Comment

You must log in to post.