Please or Register to create posts and topics.

Inherit forum subscription for topics

I am looking for a way for topics within a forum to inherit the subscription of the forum itself -- so that if I am subscribed to a forum, I get notification on new topics, and also automatically on replies to those topics. I understand there is a hesitancy to provide this in general due to EU privacy restrictions (even though the user has in fact opted-in to receiving the emails for the forum), but as this is a invitation-only small US site, I think I'm good there. So I'm looking for hints on how to set this up. I see lots of tricks to automatically subscribe users to things, but that's not actually what I want -- I want to respect the user's choice for the forum globally (including if they change the global setting).

In case anyone is interested, this does the trick (but I suppose is not completely efficient):

add_action('asgarosforum_after_add_topic_submit', 'subscribe_new_topic', 10, 6);
function subscribe_new_topic($post_id, $topic_id, $topic_subject, $topic_content, $topic_link, $author_id) {
    $asgarosforum = new AsgarosForum();
    $topic = $asgarosforum->content->get_topic($topic_id);
    $users = get_users( array('fields' => 'all'));
    foreach ($users as $user) {
        $subscribedForums = get_user_meta($user->ID, 'asgarosforum_subscription_forum');
        if (in_array($topic->parent_id, $subscribedForums)) {
            add_user_meta( $user->ID, 'asgarosforum_subscription_topic', $topic->id, false);


Jim has reacted to this post.

I don't understand why this would be needed.  What is the point of forum subscription if you don't get notified of new topics and replies in the forum?  What does forum subscription do, if not that?

EDIT: After testing, I find that subscribing to a forum notifies you of new topics only, not replies to the topics.  So yes, apparently the code is needed to do that.