email new entries for all users? (Features)

by novacultura @, Tuesday, July 17, 2012, 11:35 (4294 days ago)

Hi there,
is there a possibility to let all users get emails for new entries?
At the moment only "mods" and "admins" can click this possibility.
But I would not want to upgrade all users of my forum to moderators, just to let them recieve new entries emails.
Hope you can help me.

Thanks
Michael

Avatar

email new entries for all users?

by Auge ⌂, Wednesday, August 01, 2012, 22:08 (4278 days ago) @ novacultura

Hello

is there a possibility to let all users get emails for new entries?
At the moment only "mods" and "admins" can click this possibility.
But I would not want to upgrade all users of my forum to moderators, just to let them recieve new entries emails.

For the archive:

No, this function is not implemented and it should not (as described). Why should every user receive an email in case of every new posting? A IMHO better way is the possibility to subscribe every single thread. So I as user decide wich threads are important for me.

Tschö, Auge

--
Trenne niemals Müll, denn er hat nur eine Silbe!

email new entries for all users?

by novacultura @, Thursday, August 02, 2012, 05:26 (4278 days ago) @ Auge

Why should every user receive an email in case of every new posting?

because in at least one of the forums I do with MLF, the users want to.
The reason is simple: They are used to mailing lists and not to log in every day to the forum to check new entries. So the want to have the POSSIBILITY (as an option) to be notified in the case.

And then they can - as you say - decide, wether a thread is interesting for them or not, and log in or not.

A IMHO better way is the possibility to subscribe every single thread.

this is not a better way, but a completely different option.

Thanks
Michael

Avatar

email new entries for all users?

by Micha ⌂, Thursday, August 02, 2012, 05:51 (4278 days ago) @ novacultura

Hi Michael,

not to log in every day to the forum to check new entries. So the want to have the POSSIBILITY (as an option) to be notified in the case.

They can use the RSS-Feed to get an information about new threads. So, they don't have to log in every day.

regards
Micha

--
applied-geodesy.org - OpenSource Least-Squares Adjustment Software for Geodetic Sciences

email new entries for all users?

by Martin de oude ⌂ @, The Dutch, Thursday, August 02, 2012, 07:07 (4278 days ago) @ Micha
edited by Martin de oude, Thursday, August 02, 2012, 07:15

Use MLF for quick messages and on the normal website usage in the RSS feeds:

just look

www.leidschenveen.com

and the mlf site www.alert.leidschenveen.com

Google translated from Dutch into English

email new entries for all users?

by novacultura @, Friday, August 10, 2012, 09:10 (4270 days ago) @ Martin de oude

Hi Martin,
sorry, I did not understand what you did with your website :-(
What is the advantage for people who do not want to log in to a site every day and recieve emails instead? Would your techology help. I would be grateful for any further explanation.

The RSS is no real solution, because it requires the forum to be open for all. The forum I am trying to establish is a quite restricted group of people who are not really used to dealing with IT - in fact some of them are afraid of it :-D . So it must be really easy by every means.

Is is really so difficult to give all users the right to recieve emails on new entries?
The only alternative I see at the moment is to give them all the status as "moderators" which would give them the right to erase threads etc.. and no one of them wants to take that risk ...

Any other ideas?
Thanks a lot
Michael

Avatar

Possible, but not a good idea

by Alfie ⌂, Vienna, Austria, Saturday, August 11, 2012, 21:38 (4268 days ago) @ novacultura

Hi Michael!

The RSS is no real solution, because it requires the forum to be open for all.

That doesn’t matter. My forum is also limited to registered users (precisely: to post, but not to read) and the RSS is still available to everybody.

Is is really so difficult to give all users the right to recieve emails on new entries?

No, it isn’t. I implemented this option in my forum where the majority of members come from developing countries. ~25% are still using IE6. RSS-Reader – never heard of. Now for the big but: I made this statement in the instructions:
“Please tick the E-mail notification box only if you cannot use the RSS Feed. Using the notification may result in a lot of e-mail traffic, not only to you personally, but the forum’s e-mail server may be classified as a bulk-mailer / spammer and blacklisted – which could affect all users.”
Luckily only less than 1% of users have opted in (which still results in up to 300 e-mails / day).

--
Cheers,
Alfie (Helmut Schütz)
BEBA-Forum (v1.8β)

Possible, but not a good idea

by novacultura @, Sunday, August 12, 2012, 15:13 (4268 days ago) @ Alfie

Wow! That gives me hope.
I am talking of a quite small forum for a restricted community of translators, so I won't be afraid of being classified as spammer. Far away from that, I fear.

But may I ask how you implemented this option?
I have only rudimentary knowledge of php, unfortunately.

Thanks in advance
Michael

Avatar

Possible, but not a good idea

by Alfie ⌂, Vienna, Austria, Sunday, August 12, 2012, 18:04 (4268 days ago) @ novacultura

Hi Michael!

But may I ask how you implemented this option?

Actually my version is 1.8β – so the method differs and I am not familiar with this part of v2’s code. Sorry.

--
Cheers,
Alfie (Helmut Schütz)
BEBA-Forum (v1.8β)

Avatar

Possible, but not a good idea

by Auge ⌂, Wednesday, August 15, 2012, 20:36 (4264 days ago) @ novacultura

Wow! That gives me hope.
I am talking of a quite small forum for a restricted community of translators, so I won't be afraid of being classified as spammer. Far away from that, I fear.

But may I ask how you implemented this option?
I have only rudimentary knowledge of php, unfortunately.

I implemented it in an easy way for mlf2 version 2.3. Every user, who has activated the user setting for being able to receive personal messages via the contact form will be notified about new entries in the forum. Otherwise the users will not informed about new entries.

1. Add the following function to includes/functions.inc.php

/**
 * sends an e-mail notification to all users if a reply was
 * posted and a notification was requested
 *
 * @param int $id : the id of the reply
 * @param bool $delayed : true adds a delayed message (when posting was activated manually)
 */
function emailNotification2AllUsers($id, $delayed=false)
 {
  global $settings, $db_settings, $lang, $connid;
  // check for 'notification for all registered users'-setting
  if ($settings['email_notification_2_all'] != 1) return false;
  $id=intval($id);
  // data of posting:
  $result = @mysql_query("SELECT pid, tid, name, user_name, ".$db_settings['forum_table'].".user_id, subject, text
                          FROM ".$db_settings['forum_table']."
                          LEFT JOIN ".$db_settings['userdata_table']." ON ".$db_settings['userdata_table'].".user_id=".$db_settings['forum_table'].".user_id
                          WHERE id = ".intval($id)." LIMIT 1", $connid);
  $data = mysql_fetch_array($result);
  mysql_free_result($result);
  // overwrite $data['name'] with $data['user_name'] if registered user:
  if($data['user_id']>0)
   {
    if(!$data['user_name']) $data['name'] = $lang['unknown_user'];
    else $data['name'] = $data['user_name'];
   }
  // data of registered users, who wants to receive notifications
  $result = @mysql_query("SELECT user_name, user_email FROM ".$db_settings['userdata_table']." WHERE email_contact = 1", $connid);
  // return false in case of empty result
  if (mysql_num_rows($result) == 0) return false;
  // generate static content of the email
  $name = $data['name'];
  $subject = $data['subject'];
  $text = email_format($data['text']);
  // cut the email template at the point, where the parent posting should be encluded
  $emailbody = substr($lang['email_text'], 0, strrpos($lang['email_text'], '[posting_address]') + 17);
  $emailbody = str_replace("[name]", $name, $emailbody);
  $emailbody = str_replace("[subject]", $subject, $emailbody);
  $emailbody = str_replace("[text]", $text, $emailbody);
  $emailbody = str_replace("[posting_address]", $settings['forum_address']."index.php?id=".$id, $emailbody);
  $emailbody = str_replace("[forum_address]", $settings['forum_address'], $emailbody);
  if($delayed==true) $emailbody = $emailbody . "\n\n" . $lang['email_text_delayed_addition'];
  // get content of the parent posting
  if ($data['pid'] > 0)
   {
    $parent_result = mysql_query("SELECT name, subject FROM ".$db_settings['forum_table']." WHERE id = ".intval($data['pid'])." LIMIT 1", $connid);
    $parent_data = mysql_fetch_assoc($parent_result);
    mysql_free_result($parent_result);
    $emailbody = str_replace("[original_subject]", $parent_data['subject'], $emailbody);
   }
  else
   {
    $emailbody = str_replace("[original_subject]", '---', $emailbody);
   }
  while ($note = mysql_fetch_assoc($result))
   {
    $dynamicbody = $emailbody;
    $dynamicbody = str_replace("[recipient]", $note['user_name'], $dynamicbody);
    $recipient = $note['user_email'];
    my_mail($recipient, $subject, $dynamicbody);
    unset($dynamicbody);
   }
  mysql_free_result($result);
 }

2. Use this funtion in posting.inc.php after lines 925 and 1527.

        // e-mail notification to admins and mods
        if($spam==0) emailNotification2ModsAndAdmins($new_data['id']);
 
        // e-mail notification to all users (the new lines)
        if($spam==0) emailNotification2AllUsers($new_data['id']);


and

        emailNotification2ParentAuthor($id, true);
        emailNotification2ModsAndAdmins($id, true);
        emailNotification2AllUsers($id, true); // the new line

3. Add a new setting via phpMyAdmin or a similar tool. Open the table mlf2_settings and insert a new row.

name: email_notification_2_all
value: 1

I tested the code in a test environment with only one user and it worked. Please test the code well in your own forum. Other functions are not affected.

Tschö, Auge

--
Trenne niemals Müll, denn er hat nur eine Silbe!

Possible, but not a good idea

by novacultura @, Thursday, August 16, 2012, 09:28 (4264 days ago) @ Auge

Hey,that's great!
Thank you very much Auge, for making my strange idea possible.
I'll check it out, and if it works with me, I'll tell you.
All the best
Michael

Possible, but not a good idea

by mkjjj, Thursday, September 27, 2012, 08:55 (4222 days ago) @ novacultura

Hi Auge,

thanks for the mod. It works! The only problem is that users can't deactivate this feature (if they want to keep the email contact feature). I would prefer the same functionality like Admins and Mods have. I've changed the user_edit.inc.tpl from

{if $mod||$admin}
<tr>
<td class="c"><strong>{#edit_user_notification#}</strong></td>
<td class="d"><input id="new_posting_notification" type="checkbox" name="new_posting_notification" value="1"{if $new_posting_notification=="1"} checked="checked"{/if} /><label for="new_posting_notification">{#admin_mod_notif_posting#}</label><br />
<input id="new_user_notification" type="checkbox" name="new_user_notification" value="1"{if $new_user_notification=="1"} checked="checked"{/if} /><label for="new_user_notification">{#admin_mod_notif_register#}</label></td>
</tr>
{/if}

to

<tr>
<td class="c"><strong>{#edit_user_notification#}</strong></td>
<td class="d"><input id="new_posting_notification" type="checkbox" name="new_posting_notification" value="1"{if $new_posting_notification=="1"} checked="checked"{/if} /><label for="new_posting_notification">{#admin_mod_notif_posting#}</label><br />
{if $mod||$admin}<input id="new_user_notification" type="checkbox" name="new_user_notification" value="1"{if $new_user_notification=="1"} checked="checked"{/if} /><label for="new_user_notification">{#admin_mod_notif_register#}</label>{/if}</td>
</tr>

And in the user_inc.php:

   if($_SESSION[$settings['session_prefix'].'user_type']==1||$_SESSION[$settings['session_prefix'].'user_type']==2)
        {
         $smarty->assign('new_posting_notification', $row['new_posting_notification']);
         $smarty->assign('new_user_notification', $row['new_user_notification']);
        }

to

$smarty->assign('new_posting_notification', $row['new_posting_notification']);
         $smarty->assign('new_user_notification', $row['new_user_notification']);

and

     if(isset($_POST['user_view'])) $user_view = intval($_POST['user_view']); else $user_view=0;
       if($user_view!=0&&$user_view!=1&&$user_view!=2) $user_view = 0;
       if($_SESSION[$settings['session_prefix'].'user_type']==1||$_SESSION[$settings['session_prefix'].'user_type']==2)
        {
         if(isset($_POST['new_posting_notification']) && $_SESSION[$settings['session_prefix'].'user_type']>0) $new_posting_notification = intval($_POST['new_posting_notification']);
         else $new_posting_notification = 0;
         if($new_posting_notification!=0&&$new_posting_notification!=1) $new_posting_notification=0;
         if(isset($_POST['new_user_notification']) && $_SESSION[$settings['session_prefix'].'user_type']>0) $new_user_notification = intval($_POST['new_user_notification']);
         else $new_user_notification = 0;
         if($new_user_notification!=0&&$new_user_notification!=1) $new_user_notification=0;
        }
       else

to

    if(true)
        {
         if(isset($_POST['new_posting_notification'])) $new_posting_notification = intval($_POST['new_posting_notification']);
         else $new_posting_notification = 0;
         if($new_posting_notification!=0&&$new_posting_notification!=1) $new_posting_notification=0;
         if(isset($_POST['new_user_notification'])) $new_user_notification = intval($_POST['new_user_notification']);
         else $new_user_notification = 0;
         if($new_user_notification!=0&&$new_user_notification!=1) $new_user_notification=0;
        }
       else

While this makes the checkbox available for all registered users and keeps the setting, no emails are sent. Obviously, something is missing.

Any ideas would be very appreciated!

Mike

Possible, but not a good idea

by mkjjj, Thursday, September 27, 2012, 14:28 (4222 days ago) @ mkjjj

Hallo,

I changed line 2666 in functions.inc.php from

$result = @mysql_query("SELECT user_name, user_email FROM ".$db_settings['userdata_table']." WHERE email_contact = 1", $connid);

to

$result = @mysql_query("SELECT user_name, user_email FROM ".$db_settings['userdata_table']." WHERE email_contact = 1 AND new_posting_notification = 1 AND user_type = 0", $connid);

It seems to work fine for users. They can switch the notification on and off. Admin and Mods won't get two notifications (they would without the user_type condition).

Would be nice to have this as a standard feature. RSS feeds are great, but not an option for a forum that is not public. In this case it might be important for non-admins to get a notification for each new posting.

Mike

Avatar

Possible, but not always a good idea

by Rövarn ⌂, Saturday, May 28, 2016, 12:29 (2883 days ago) @ Auge

This is an old thread, but I recently found the need to send mail to all members of some of the forums I sat up, these forums are used as information center to the boards of associations and does not have many members. The forums is the latest version 2.3.4

A very, very, very simple hack to send mail to all members when new posts or replies are submitted is a tiny change in line 1519 in the file /includes/functions.inc.php from:

  $recipient_result = @mysql_query("SELECT user_name, user_email FROM ".$db_settings['userdata_table']." WHERE user_type > 0 AND new_posting_notification=1", $connid) or raise_error('database_error',mysql_error());

to:

  $recipient_result = @mysql_query("SELECT user_name, user_email FROM ".$db_settings['userdata_table']." WHERE user_type > 0 OR user_lock=0", $connid) or raise_error('database_error',mysql_error());

It works and covers the needs I have, but should be used with caution if the forum has many members!

--
Just for fun...
[image]

Can the dev team confirm this is a valid hack

by Jean-Michel2 @, Sunday, February 17, 2019, 11:44 (1888 days ago) @ Rövarn

Hello,

I'm also setting up a forum where all people (less than 10) need to be informed of all new posts. I guess the "NEW_POSTING" that is deleted from the code refers to the option on the user form for a moderator to receive new posts ? And "user-lock>0" is added to avoid that locked users would also receive the notifications (quite annoying indeed!).

Can the dev team confirm that this hack is OK and that there is no other thing to take into account?

Kind regards,

Jean-Michel

Avatar

Can the dev team confirm this is a valid hack

by Auge ⌂, Monday, February 18, 2019, 12:04 (1887 days ago) @ Jean-Michel2

Hello

I guess the "NEW_POSTING" that is deleted from the code refers to the option on the user form for a moderator to receive new posts ?

To be honest, I don't know, what you are talking about.

And "user-lock>0" is added to avoid that locked users would also receive the notifications (quite annoying indeed!).

Yes.

Can the dev team confirm that this hack is OK and that there is no other thing to take into account?

The thread is very old. With exception of the posting, you are replying to, the thread is seven years of age. Currently we are on 2.4.19.1, my seven years old solution was for 2.3(.0) and at the time, Rövarn wrote his reply, the version 2.3.4 was up-to-date (as he stated in his posting).

The solution might work with the up-to-date version but sorry, I will not give any guarantee, not for the function of the code nor for it's completeness.

Tschö, Auge

--
Trenne niemals Müll, denn er hat nur eine Silbe!

RSS Feed of thread