Please or Register to create posts and topics.

Stimulate forum use by sending new posts to all members

Hi Asgaros

Can you please advise how I can set the forum so that all members receive all new topics/posts that are made, whether or not the member has already subscribed to the relevant forum.  This is only for new topics/posts, not subsequent replies.  The member would have to log into the forum and subscribe should they want to receive any further posts on that subject.

I suspect this will involve using a hook?  In which case, are there are step-by-step instructions?

Many thanks

Hello @davo

Currently there is no option for this available because of legal reasons. In a couple of countries there are strict privacy rules which dont allow you as a site-owner to send mails to users without their agreement. If you really want to do this its on your own risk.

In this case I think the asgarosforum_subscriber_mails_new_topic filter is the way to go. With this filter you can modify the array containing the mails of users who should get notified about a new topic right before the mails are sent.

Here is an example code which you can add to your themes functions.php file:

 

function notify_about_new_topic_mails($mails) {
  $users = get_users();

  foreach ($users as $user) {
    if (!in_array($user->user_email, $mails)) {
            $mails[] = $user->user_email;
        }
  }
  
  return $mails;
}
add_filter('asgarosforum_subscriber_mails_new_topic', 'notify_about_new_topic_mails');

 

If you want to support the development of Asgaros Forum, you can leave a good review or donate. Thank you very much!

Thanks Asgaros

My theme requires that a child theme is set up.  I’ll get this done and enter the information you’ve provided.  Fingers crossed!

 

 

Hi

I have got this to work in that new topics are being emailed to all members however I have a problem… the emails from all categories are being sent out to all members.  Why is that a problem?  Let’s say I have Moderators and have identified those members who are Moderators in the Forum User Group settings.  These Moderators have their own forum category and posts made in that category are not seen by members who are not Moderators.  However, the asgarosforum_subscriber_mails_new_topic filter is sending out new topics in the Moderators’ forum to all members.  Is there a way to filter new topics made in the relevant forum to the correct user group?

Hello @davo

I think there is no easy solution for this because that would require a lot of filtering-logic.

A possible another way: You can use some hook which automatically subscribes new registered users to all new topics – including access-filtering. After it they still have the possibility to opt-out from it:

add_action('user_register', 'auto_subscribe', 10, 1);

public function auto_subscribe($user_id) {
    delete_user_meta($user_id, 'asgarosforum_subscription_global_posts');
    update_user_meta($user_id, 'asgarosforum_subscription_global_topics', 1);
}

 

If you want to support the development of Asgaros Forum, you can leave a good review or donate. Thank you very much!

Thanks for coming back, Asgaros.  I’ll have a play!

Asgaros has reacted to this post.
Asgaros