bbPress Plugin Browser »

Post Notification (1.4)

Download

Version: 1.4

Other Versions

Last Updated: 2009-2-25

Author Homepage »

Plugin Homepage »

Average Rating

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

Your Rating

Author: Thomas Klaiber


  1. test4 (and others interested) to NOT notify a user about their own post try this (untested):

    around line 16:
    change
    if ( notification_is_activated( $userdata->ID ) ) :
    to
    if ($bb_current_user->ID!=$userdata->ID && notification_is_activated( $userdata->ID ) ) :

    This could also be accomplished via the function notification_select_all_users during the mysql query by excluding the current user.

    This (should) work because the person making the post is the one triggering all the emails.

    Posted: 3 years ago #
  2. Great plugin! I am trying to reverse the default activation for all users. That is make the notification feature active on default for all users. The function starts by declaring '$checked = "";' if I set that equal to 'checked' it works, but users can not deactivate it. I started playing around with the notification_is_activated function, but I just don't know what I'm doing, and got lost. Any help?

    Posted: 3 years ago #
  3. Is there a way to add all new topics to the user who started it AND the ADMINS?

    Posted: 3 years ago #
  4. Ok it seems I am kind of silly but how can I add the check box that users need to check to activate the option "subscribe by email to favorite topics"?
    Because I cannot find it and my theme is a customized version.

    I would gladly appreciate any help.

    Does it help if I say : _ck_ you rock! (lol!!!!)

    Posted: 3 years ago #
  5. If the checkbox is not appearing and you have a custom theme, you may be missing some of the needed actions in the template to trigger it.

    Also if you are using 1.0 alpha this has not been tested with it yet so it might be that as well.

    You can try temporarily switching back to kakumei theme and see if the box appears.

    Note the checkbox is in the EDIT PROFILE section and not on the topic page.

    Posted: 3 years ago #
  6. jennygold

    Member

    I've adapted this plugin to work when a new topic is submitted by using add_action('bb_new_topic', 'notification_new_topic') instead of bb_new_post with a function I've named notification_new_topic. The problem is I tried to use the existing variables to get the title, link and author passed into the email, but they don't seem to be available when I use bb_new_topic. What variables are available and how would I get these fields to be automatically filled in on the email?

    Thanks!

    Posted: 3 years ago #
  7. Works perfectly. Only mod I could think of is to have it go to the permalink generating the email instead of the post (and thats preference more than anything) but A+!

    Posted: 3 years ago #
  8. danbbpress

    Member

    Even if you manage to make all posts favorites for their posters, they still need to check the Notification radio button to get notifications. And this radio button is difficult to locate in my opinion. I think this notification button should be turned on by default because most people expect to get notified when a new reply was added to a thread they initiated/participated in.

    Posted: 3 years ago #
  9. Lemonade Joe

    Member

    Hi, I am trying to use this plugin on a site running in Slovak language, that means, I need to use special characters. I am not good with php, so forgive me, if am not technical enough :)

    The system e-mails (like registration) are working fine. However, when sending mail through Post Notification, the special characters are messed up.

    When I was checking the source code of the mails, I have discovered, that the registration mails contain the line "Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="UTF-8"".
    The Post Notification mails (also the Report Post plugin mails) do not contain any charset specification (the source code contains this: X-Amavis-Alert: BAD HEADER SECTION, Non-encoded 8-bit data (char C3 hex).
    Can that be the source of my problem, if yes, how can I solve it?

    Posted: 2 years ago #
  10. Skip Savage

    Member

    For some unknown reason I cannot get anything to appear on my Favorites page. I activate. Refresh. Try stock theme. Revert to custom theme. Choose favorite topics. Uncheck favorite topics. Deactivate. Reactivate.

    I would like this to work for me. Seems essential.

    Posted: 2 years ago #
  11. Skip Savage

    Member

    I found the checkbox. My mistake thinking it would be on the Favorites pages. Found it on the Edit Profile form. Perhaps others will learn from my false assumption.

    Posted: 2 years ago #
  12. Hi,
    Is it possible to send notification of any post, topic or forum created in the forum? I need only one global level 'tick', so the user receive email notification of forum activities.
    Thanks.
    Etchbee

    Posted: 2 years ago #
  13. Hi,

    I just commented following line 17, it worked for me. So all users who activate favorite post will receive email notification whenever new post/topic/forum created.

    //if ( is_user_favorite( $userdata->ID, $topic_id ) ) :

    Thanks me and Thomas. Ha ha.

    Etchbee

    Posted: 2 years ago #
  14. Is there any way to automatically subscribe users to any thread they post in, and notify them by e-mail of updates to that thread? I haven't found a plugin like that, but that's what I really need!

    Posted: 2 years ago #
  15. bbn

    Member

    Hi,

    We re-architected part of this plugin. The bbpress forum for Cycling '74 (http://cycling74.com/forums) has more than 15,000 users. After a new post this plugin was loading every single user record, then iterating through them to check the metadata for each user and see if the user had flagged the topic as a favorite. Tens of thousands of database queries.

    Instead of using the stored list of favorite topic_ids in the user meta-dataspace, we solved the problem by adding functions that manage the storing of user_ids in the topic meta-space. So the number of database queries is 1. Below is the code. Feel free to incorporate it into the next version of the plugin.


    function add_user_to_topic_favorites( $user_id, $topic_id ) {
    $user_id = (int) $user_id;
    $topic_id = (int) $topic_id;

    $topic = get_topic( $topic_id );
    if ( !$topic )
    return false;

    $fav = $topic->user_id_favorites ? explode(',', $topic->user_id_favorites) : array();
    if ( ! in_array( $user_id, $fav ) ) {
    $fav[] = $user_id;
    $fav = implode(',', $fav);
    bb_update_topicmeta( $topic_id, 'user_id_favorites', $fav);
    }
    }
    add_action('bb_add_user_favorite', 'add_user_to_topic_favorites',10,2);

    function remove_user_from_topic_favorites( $user_id, $topic_id ) {
    $user_id = (int) $user_id;
    $topic_id = (int) $topic_id;
    $topic = get_topic( $topic_id );
    if ( !$topic )
    return false;
    if ( !$topic->user_id_favorites )
    return false;

    $fav = explode(',', $topic->user_id_favorites);
    if ( is_int( $pos = array_search($user_id, $fav) ) ) {
    array_splice($fav, $pos, 1);
    $fav = implode(',', $fav);
    bb_update_topicmeta( $topic_id, 'user_id_favorites', $fav);
    }

    }
    add_action('bb_remove_user_favorite', 'remove_user_from_topic_favorites',10,2);

    function notification_new_post($post_id=0) {
    global $bbdb, $bb_table_prefix, $topic_id, $bb_current_user;

    $topic = get_topic( $topic_id );
    if ( !$topic )
    return false;
    if ( !$topic->user_id_favorites )
    return false;
    $users = $bbdb->get_results("SELECT ID, user_email FROM $bbdb->users WHERE id IN (".$topic->user_id_favorites.")");

    foreach ($users as $userdata) :
    $message = __("There is a new post on: %1\$s \nReply by: %2\$s \nText: %3\$s \n\n%4\$s ");
    mail( $userdata->user_email, bb_get_option('name') . ': ' . __('Notification'),
    sprintf( $message, get_topic_title($topic_id), get_user_name($bb_current_user->ID), strip_tags(get_post_text($post_id)), get_topic_link($topic_id) ),
    'From: '.bb_get_option('name').' <'.bb_get_option('from_email').'>'
    );
    endforeach;

    }
    add_action('bb_new_post', 'notification_new_post');

    Posted: 2 years ago #
  16. Hmm I can't help you! I tried it with the newest version of bbpress and it works without any problems ...

    Have you installed any other plugins?

    http://methoo.com

    Posted: 2 years ago #
  17. This version says 1.4. I guess this is more up to date than the plugin website?

    EDIT: other comments were about the wrong plugin

    Posted: 2 years ago #
  18. I have also made some changes to this plugin. I contacted Thomas Klaiber who said that he liked my additions, but that he no longer supported the plugin and said I should just post my version here.

    These are the modifications I've made:

    - Send mail in UTF-8 format so Danish, Swedish, Russian etc. characters display correctly.
    - User can select whether to get a mail on favorite topics or all topics.
    - Changed subject of mail to show which topic is updated (forum-name:topic). Also 'from:' is now set to the username of the poster instead of the forum name, which makes your inbox so much more tidy.

    <?php
    /**
     * Plugin Name: Post Notification
     * Plugin Description: Sends a Notification email if there's a new post to a favorite topic.<br>(Modified Version 1.4 with Post Content included in E-Mail)<br>(And modified to send mail in utf8 format so danish, swedish, russian etc. characters display correctly).<br>Also modified so user can select whether to get a mail on favorite topics or all topics.<br>Changed subject of email to show which topic is updated - and from: is now set to the username of the poster instead of the forum name.
     * Author: Thomas Klaiber
     * Author URI: http://thomasklaiber.com/
     * Plugin URI: http://thomasklaiber.com/bbpress/post-notification/
     * Version: 1.4.x
     */
    
    function notification_new_post($post_id=0) {
      global $bbdb, $bb_table_prefix, $topic_id, $bb_current_user;
    
      $all_users = notification_select_all_users();
      foreach ($all_users as $userdata) :
        if ( notification_is_activated( $userdata->ID ) && $userdata->ID != $bb_current_user->ID) :
          if (notification_all_is_activated( $userdata->ID ) || is_user_favorite( $userdata->ID, $topic_id ) ) :
            $message = __("There is a new post on:\n %1\$s \n\nReply by:\n %2\$s \n\nText:\n %3\$s \n\n%4\$s ");
              mail_utf8( $userdata->user_email, bb_get_option('name') . ': ' . get_topic_title($topic_id), sprintf( $message, get_topic_title($topic_id), get_user_name($bb_current_user->ID), strip_tags(get_post_text($post_id)), get_topic_link($topic_id) ), 'From: '.get_user_name($bb_current_user->ID).' <'.bb_get_option('from_email').'>'
              );
          endif;
        endif;
      endforeach;
    }
    add_action('bb_new_post', 'notification_new_post');
    
    function mail_utf8($to, $subject = '(No subject)', $message = '', $header = '') {
      $header_ = 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/plain; charset=UTF-8' . "\r\n";
      mail($to, '=?UTF-8?B?'.base64_encode($subject).'?=', $message, $header_ . $header);
    } 
    
    function notification_select_all_users() {
      global $bbdb;
    
      $all_users = $bbdb->get_results("SELECT ID, user_email FROM $bbdb->users WHERE user_status=0");
    
      return $all_users;
    }
    
    function notification_profile() {
      global $user_id, $bb_current_user;
    
      if ( bb_is_user_logged_in() ) :
    
        $checked = "";
        if (notification_is_activated($user_id)) :
          $checked = "checked='checked'";
        endif;
    
        $checked_all_on = "";
        $checked_all_off = "checked='checked'";
        if (notification_all_is_activated($user_id)) :
          $checked_all_on = "checked='checked'";
          $checked_all_off = "";
        endif;
    
        echo "<fieldset>
    <legend>Favorite Notification</legend>
    <p> " . __('Email me when there'."'".'s a new post in a topic.') . "</p>
    <table width=\"100%\">
    <tr>
    <th width=\"21%\" scope=\"row\">" . __("Activate Notification") . ":</th>
    <td width=\"79%\" ><input name=\"favorite_notification\" id=\"favorite_notification\" type=\"checkbox\" value=\"1\"" . $checked . " /></td>
    </tr>
    </table>
    <p> " . __('When should the system send an email?') . "</p>
    <table width=\"100%\">
    <tr>
    <th width=\"21%\" scope=\"row\">" . __("Only favorites") . ":</th>
    <td width=\"79%\" >
    <input name=\"favorite_notification_all\" id=\"favorite_notification_all\" type=\"radio\" value=\"0\"" . $checked_all_off . " /></td>
    </tr>
    <tr>
    <th width=\"21%\" scope=\"row\">" . __("All topics") . ":</th>
    <td width=\"79%\" >
    <input name=\"favorite_notification_all\" id=\"favorite_notification_all\" type=\"radio\" value=\"1\"" . $checked_all_on . " /></td>
    </tr>
    </table>
    </fieldset>\n\n";
      endif;
    }
    add_action('extra_profile_info', 'notification_profile');
    
    function notification_profile_edit() {
      global $user_id;
    
      bb_update_usermeta($user_id, "favorite_notification", $_POST['favorite_notification']);
      bb_update_usermeta($user_id, "favorite_notification_all", $_POST['favorite_notification_all']);
    }
    add_action('profile_edited', 'notification_profile_edit');
    
    function notification_is_activated($user_id) {
      $user = bb_get_user( $user_id );
      if ($user->favorite_notification) :
        return true;
      else :
        return false;
      endif;
    }
    
    function notification_all_is_activated($user_id) {
      $user = bb_get_user( $user_id );
      if ($user->favorite_notification_all) :
        return true;
      else :
        return false;
      endif;
    }
    ?>
    Posted: 1 year ago #
  19. DKB

    Member

    I have problem with this plugin and the auto add favorites plugin:

    If i uncheck the boxes and save then it again shows as checked.

    Any clue?

    Posted: 1 year ago #
  20. For some reason the uncheck didn't register in the database when I used a checkbox. I've made a version that uses radio-buttons instead.

    (I can't edit my old post, so sorry for the inconvenience with the extra code...)

    <?php
    /**
    * Plugin Name: Post Notification
    * Plugin Description: Sends a Notification email if there's a new post to a favorite topic.
    (Modified Version 1.4 with Post Content included in E-Mail)
    (And modified to send mail in utf8 format so danish, swedish, russian etc. characters display correctly).
    Also modified so user can select whether to get a mail on favorite topics or all topics.
    Changed subject of email to show which topic is updated - and from: is now set to the username of the poster instead of the forum name.
    * Author: Thomas Klaiber
    * Author URI: http://thomasklaiber.com/
    * Plugin URI: http://thomasklaiber.com/bbpress/post-notification/
    * Version: 1.4.x
    */

    function notification_new_post($post_id=0) {
    global $bbdb, $bb_table_prefix, $topic_id, $bb_current_user;

    $all_users = notification_select_all_users();
    foreach ($all_users as $userdata) :
    if ( notification_is_activated( $userdata->ID ) && $userdata->ID != $bb_current_user->ID) :
    if (notification_all_is_activated( $userdata->ID ) || is_user_favorite( $userdata->ID, $topic_id ) ) :
    $message = __("There is a new post on:\n %1\$s \n\nReply by:\n %2\$s \n\nText:\n %3\$s \n\n%4\$s ");
    mail_utf8( $userdata->user_email, bb_get_option('name') . ': ' . get_topic_title($topic_id), sprintf( $message, get_topic_title($topic_id), get_user_name($bb_current_user->ID), strip_tags(get_post_text($post_id)), get_topic_link($topic_id) ), 'From: '.get_user_name($bb_current_user->ID).' <'.bb_get_option('from_email').'>'
    );
    endif;
    endif;
    endforeach;
    }
    add_action('bb_new_post', 'notification_new_post');

    function mail_utf8($to, $subject = '(No subject)', $message = '', $header = '') {
    $header_ = 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/plain; charset=UTF-8' . "\r\n";
    mail($to, '=?UTF-8?B?'.base64_encode($subject).'?=', $message, $header_ . $header);
    }

    function notification_select_all_users() {
    global $bbdb;

    $all_users = $bbdb->get_results("SELECT ID, user_email FROM $bbdb->users WHERE user_status=0");

    return $all_users;
    }

    function notification_profile() {
    global $user_id, $bb_current_user;

    if ( bb_is_user_logged_in() ) :

    $checked_on = "checked='checked'";
    $checked_off = "";
    if (!notification_is_activated($user_id)) :
    $checked_on = "";
    $checked_off = "checked='checked'";
    endif;

    $checked_all_on = "";
    $checked_all_off = "checked='checked'";
    if (notification_all_is_activated($user_id)) :
    $checked_all_on = "checked='checked'";
    $checked_all_off = "";
    endif;

    echo "<fieldset>
    <legend>Favorite Notification</legend>
    <p> " . __('Email me when there'."'".'s a new post in a topic.') . "</p>
    <table width=\"100%\">
    <tr>
    <th width=\"21%\" scope=\"row\">" . __("Activate") . ":</th>
    <td width=\"79%\" ><input name=\"favorite_notification\" id=\"favorite_notification\" type=\"radio\" value=\"1\"" . $checked_on . " /></td>
    </tr>
    <tr>
    <th width=\"21%\" scope=\"row\">" . __("Deactivate") . ":</th>
    <td width=\"79%\" ><input name=\"favorite_notification\" id=\"favorite_notification\" type=\"radio\" value=\"0\"" . $checked_off . " /></td>
    </tr>
    </table>
    <p> " . __('When should the system send an email?') . "</p>
    <table width=\"100%\">
    <tr>
    <th width=\"21%\" scope=\"row\">" . __("Only favorites") . ":</th>
    <td width=\"79%\" >
    <input name=\"favorite_notification_all\" id=\"favorite_notification_all\" type=\"radio\" value=\"0\"" . $checked_all_off . " /></td>
    </tr>
    <tr>
    <th width=\"21%\" scope=\"row\">" . __("All topics") . ":</th>
    <td width=\"79%\" >
    <input name=\"favorite_notification_all\" id=\"favorite_notification_all\" type=\"radio\" value=\"1\"" . $checked_all_on . " /></td>
    </tr>
    </table>
    </fieldset>\n\n";
    endif;
    }
    add_action('extra_profile_info', 'notification_profile');

    function notification_profile_edit() {
    global $user_id;
    bb_update_usermeta($user_id, "favorite_notification", $_POST['favorite_notification']);
    bb_update_usermeta($user_id, "favorite_notification_all", $_POST['favorite_notification_all']);
    }
    add_action('profile_edited', 'notification_profile_edit');

    function notification_is_activated($user_id) {
    $user = bb_get_user( $user_id );
    if ($user->favorite_notification) : return true; else : return false; endif;
    }

    function notification_all_is_activated($user_id) {
    $user = bb_get_user( $user_id );
    if ($user->favorite_notification_all) : return true; else : return false; endif;
    }
    ?>

    Posted: 1 year ago #

RSS feed for this topic

Add a Comment »

You must log in to post.