Feature #1945
open
Automatically add user to project
Added by James Turnbull almost 16 years ago.
Updated almost 7 years ago.
Description
The process of manually adding users to projects can be troublesome sometimes so I wanted to suggest a feature. If a registered user submits a ticket for a particular project then they are automatically added as a member of the project. To handle role access you should be able to specify the default role they would be added as, for example reporter.
I second this one. A setting to set what projects are allowed to auto add users would be handy in this case.
+1
We have a policy of "all projects private", because we have open the forge for our customers also, but we would like to add automatically some projects for the Members authenticated via LDAP, instead of doing manually.
I am also curious.
The use case for me is that all projects are private by default (client-based) but we have a few key people that are part of every project so they should be automatically added to everyone.
Also, it would be a nice option to specify an admin user who is part of every project just for the ability to manage tickets in arbitrary projects.
I have the same requirement. Here is the use case for us:
We allow issue creation from email in private projects to user that don't exist in redmine yet.
Mailhandler creates the user and emails him the details to login, but he needs to be manually added to the project to be able to see/update the ticket he's created.
Having the ability to automatically add the newly created user account to the project where he submited the issue (with an arbitrary role) would save us heaps of time.
ok, here is a how I hacked it.
Obviously a proper option in the one of the Admin sections would be much better.
Or even having the above to set a default and then allow overriding for issues creation by email.
Note: I tested it only with redmine 1.4.2
--- a/app/models/mail_handler.rb 2012-06-06 00:52:03.078284808 +0200
+++ b/app/models/mail_handler.rb 2012-06-06 01:16:04.897929499 +0200
@@ -402,6 +402,11 @@
if addr && !addr.spec.blank?
user = self.class.new_user_from_attributes(addr.spec, TMail::Unquoter.unquote_and_convert_to(addr.name, 'utf-8'))
if user.save
+ member = Member.new
+ member.user = user
+ member.project = Project.find_by_identifier(get_keyword(:project))
+ member.roles = [Role.find_by_name('Reporter')]
+ member.save
user
else
logger.error "MailHandler: failed to create User: #{user.errors.full_messages}" if logger
That nasty hack from Nicolas also works perfect with 2.2.3
Apply that change starting on 457.
The patch from Pettier's comment 7 is no longer available. I was able to implement a similar feature in v2.2.3 with the following changes:
In app/models/user.rb, insert at L185:
Redmine::Hook.call_hook(:model_user_after_create_success, :user => user)
From your plugin's init.rb, include something like the following:
module RedmineNewUserHook
class Hooks < Redmine::Hook::Listener
def model_user_after_create_success(context={})
[here, do stuff like add user to default projects, etc.]
end
end
end
this is handy and very usefull feature.
Also available in: Atom
PDF