Hi guys, I have a use case that’s currently not that well supported: I need to disable the activation email for invited users—including users who are invited with a link.
After I started the above topic this was implemented, but only for users invited via email.
My Discourse instance is invite-only and I am actually sending invite links via email, but not the built-in Discourse emails. I generate the invite links with a POST
request to /invites/link
and store them in an external DB, and from there I send the links to the user. So when users click the link they have in fact already verified their email, but are then asked to do it once more.
I realize my use case isn’t particularly common, so I figured I’d try to build a simple plugin to modify the required parts of Discourse to get this working the way I need it to.
I’ve got a skeleton up and running, and added a site setting (no_activation_enabled
). After searching through the core repo I guess this might be the file that needs editing:
I’m not entirely sure, but I think maybe by conditionally (if SiteSetting.no_activation_enabled
and if the user was invited by staff, perhaps invite.invited_by.staff
?) changing active
to true
in the user.attributes
could work:
user.attributes = {
email: invite.email,
username: available_username,
name: name || available_username,
active: false,
trust_level: SiteSetting.default_invitee_trust_level,
ip_address: ip_address,
registration_ip_address: ip_address
}
But how do I go about changing this from a plugin? Is that even within the scope of what plugins can do? Or can they only add things, not modify them? Or do I need to replace the entire invite_redeemer.rb
file?
I completed the introduction to plugin building, as well as this guide, but after hours trying to dig through the code base including other plugins, I feel like I’m banging my head against a wall… So if anyone has any pointers for me, I’d be super grateful!