How to remove users from User Group programmatically
Quote from markusudm on July 29, 2024, 9:50 amI already asked this on the Wordpress.org-Plugin site and I am posting this here again for visibility.
I am using Asgaros Forum on my website, and I also use WP Groups to manage my users.
In WP Groups I have two main groups: “Mitarbeiter” and “Pensionist”. “Mitarbeiter”-Users can become members of “Pensionist”, but never the other way round. All “Mitarbeiter”-Users have access to the forum and can subscribe to whatever topic or post they want. As soon as they are in the group “Pensionist” they should lose access to the forum, but not to the website.
I succeeded in denying users of “Pensionist”-group access to the forum via the WP Groups plugin, but subscribed users still get emails with links to the forum which they can now not open anymore. So I created a user-group in Asgaros forum (“Benutzerdefinierte Benutzergruppen”), added all “Mitarbeiter”-users, but not users from “Pensionist”. As soon as people are out of the Asgaros User-group they should not receive e-mail notifications anymore, as I understood it.
What I am struggling with now is that if someone is switched from WPGroups “Mitarbeiter” to WPGroups “Pensionist” I have to throw them out of the Asgaros user-group as well. I need something like a hook for functions.php, where, when I check if they are in WPGroups “Pensionist” user group, I can remove them from the Asgaros User group. Is there something like that available?
I already asked this on the Wordpress.org-Plugin site and I am posting this here again for visibility.
I am using Asgaros Forum on my website, and I also use WP Groups to manage my users.
In WP Groups I have two main groups: “Mitarbeiter” and “Pensionist”. “Mitarbeiter”-Users can become members of “Pensionist”, but never the other way round. All “Mitarbeiter”-Users have access to the forum and can subscribe to whatever topic or post they want. As soon as they are in the group “Pensionist” they should lose access to the forum, but not to the website.
I succeeded in denying users of “Pensionist”-group access to the forum via the WP Groups plugin, but subscribed users still get emails with links to the forum which they can now not open anymore. So I created a user-group in Asgaros forum (“Benutzerdefinierte Benutzergruppen”), added all “Mitarbeiter”-users, but not users from “Pensionist”. As soon as people are out of the Asgaros User-group they should not receive e-mail notifications anymore, as I understood it.
What I am struggling with now is that if someone is switched from WPGroups “Mitarbeiter” to WPGroups “Pensionist” I have to throw them out of the Asgaros user-group as well. I need something like a hook for functions.php, where, when I check if they are in WPGroups “Pensionist” user group, I can remove them from the Asgaros User group. Is there something like that available?