My forum is going to have a lot of private topics locked under categories with groups. It’s a classroom setting, so anonymous posting is pretty important. The problem is groups don’t port over when a user switches to anonymous (as can be expected).
I’ve never written a plugin before but it seems this can best be done with a plugin. When a user turns anonymous, an account is created, I assign all their current groups to the anon. Will this work? I use the API to assign and remove groups. Can I have a trigger to also apply these changes to the anonymous user?
Are there any other implications that I am not seeing?
It might be possible to test the concept by using a Data Explorer query that returns a list of anonymous usernames that are associated with the real users who are members of given group. You could then use the Bulk Add to Group functionality to add the users to the group.
Here’s a query that will return the anonymous usernames of the real users who are members of a group. You need to supply the value of the
group_name parameter before running the query.
-- string :group_name
WITH target_users AS (
user_id AS master_user_id
FROM group_users gu
JOIN groups g
ON g.id = gu.group_id
WHERE g.name = :group_name
FROM target_users tu
JOIN anonymous_users au
ON au.master_user_id = tu.master_user_id
JOIN users u
ON u.id = au.user_id
Running the query will return results that look something like this if any members of the group have entered anonymous mode:
If you are not dealing with a huge number of users, you can just copy and paste the usernames into the group’s Bulk Add form:
You need to be aware of the
anonymous account duration minutes site setting. It sets the length of time that anonymous accounts will persist for after a user has left anonymous mode.
Another thing to consider is that this might give users the impression that anonymous users are not very anonymous. It might be worth letting people know that admins on the site have the ability to associate anonymous users with their non-anonymous account.
Note that anonymous mode is not related to what happens when you anonymize a user from their admin page. In that case, the user really is anonymous and has all identifying details removed.
I’m interested in what you are trying to accomplish, but I’m not aware of any sites that are using anonymous mode in a similar way. It might be a good idea to test this out with a small group of users and see how it goes before putting a lot of effort into developing a plugin.
Thank you for the details!
It’s a classroom setting. We want the students to feel comfortable to pipe up with anything (i.e. questions that they might think are dumb). I suppose anonymous works well as it is for public forums but most of our discussions are going to be limited to specific groups.
We’ve taken this off the short-term goals we want to achieve.
I don’t want something that we need to do every time. If I were to automate this, would I be writing a plugin? Can I have a trigger that pulls a user’s groups and attaches it to their anonymous accounts as they are created? I guess I don’t need to worry about clearing the groups off of these anons since the accounts are deleted after a while.