Please or Register to create posts and topics.

Disable Notifications after removed from User Groups

I would like to only send notifications to users who are part of user groups. When a user group is disabled, I would like for them to no longer receive any email notifications for past forum participation.

Hey @devsquirrel,

please try this code snippet:

add_action('asgarosforum_subscriber_mails_new_post', 'remove_users_from_mailing_list');
add_action('asgarosforum_subscriber_mails_new_topic', 'remove_users_from_mailing_list');

function remove_users_from_mailing_list($mailing_list){
    var_dump($mailing_list);
    foreach ($mailing_list as $key => $email){
        $user = get_user_by('email', $email);
        $user_group = AsgarosForumUserGroups::getUserGroupsOfUser($user->ID);
        // remove user from mailing list if user is not in an usergroup
        if (empty($user_group)){
            unset($mailing_list[$key]);
        }
    }
    return $mailing_list;
}

It will remove any user from the mailing list if they are not assigned to an user group.

Jim has reacted to this post.
Jim
Need professional help with Asgaros Forum? Book an appointment with us at domra Web Solutions for setup and customization services. Learn more about our Toolbox for Asgaros Forum plugin to enhance your forum experience.

Hello! Thanks for that.

I’m afraid it is not exactly what we are looking for. We want to exclude notifications for specific user groups a user no longer part of, not just if they have no user groups at all.

It seems the plugin is already trying to prevent this, but we are in fact seeing notifications sent to users who were in a specific user group but aren’t anymore.

Hey @devsquirrel,

so you have users that were in a user group and subscribed to some topics that can only be accessed by this user group. After removing them from the user group they are still getting the notifications?

Need professional help with Asgaros Forum? Book an appointment with us at domra Web Solutions for setup and customization services. Learn more about our Toolbox for Asgaros Forum plugin to enhance your forum experience.

Yes, that is correct.

Hey @devsquirrel,

but this is exactly how it should work. Can you narrow this behavior down to a specific case?

It could be also helpful to run a general health check:

Health Check & Troubleshooting

And create a debug log to check for errors:

https://help.dreamhost.com/hc/en-us/articles/360029327771-Enabling-the-WordPress-Debug-log

Need professional help with Asgaros Forum? Book an appointment with us at domra Web Solutions for setup and customization services. Learn more about our Toolbox for Asgaros Forum plugin to enhance your forum experience.

Hello @devsquirrel @qualmy91

Actually the users should not get any notifications anymore after removing them from a group. The plugin should already prevent this. Can you confirm that you still have this issue and give me some details on how you set-up your forum-structure and access to it based on your usergroups?

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