Feature #1945

Automatically add user to project

Added by James Turnbull about 12 years ago. Updated about 3 years ago.

Status:NewStart date:2008-09-25
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Projects
Target version:-
Resolution:

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.


Related issues

Related to Redmine - Feature #2722: New user notification New 2009-02-11

History

#1 Updated by Sander Datema about 12 years ago

I second this one. A setting to set what projects are allowed to auto add users would be handy in this case.

#2 Updated by J Cayetano Delgado over 11 years ago

+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.

#3 Updated by Pieter Joost van de Sande almost 10 years ago

Is this one still open?

#4 Updated by Ryan Cross almost 10 years ago

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.

#5 Updated by Nicolas Brisac over 8 years ago

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.

#6 Updated by Nicolas Brisac over 8 years ago

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

#7 Updated by Gabriel Pettier over 8 years ago

I had the same issue, tried a somewhat cleaner approach, i added a hook to user creation (by external authentifier), and created a small plugin using this hook.

patch: https://github.com/tshirtman/redmine/commit/790f57d61b379b2966d6f735e00c6e37b96f3eb8

plugin: https://github.com/tshirtman/redmine_new_user_actions

It would be great to have such a hook in Redmine merged. If the hook name I chosen is incorrect, use another one, if i forgot places to add it, i can fix it, just ask, but i would really like something like this to be merged, to have a more future-proof solution.

#8 Updated by Christoffer Järnåker almost 7 years ago

That nasty hack from Nicolas also works perfect with 2.2.3
Apply that change starting on 457.

#9 Updated by Brian Kirkpatrick over 5 years ago

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

#10 Updated by Toshi MARUYAMA over 5 years ago

#11 Updated by Yar n about 3 years ago

this is handy and very usefull feature.

Also available in: Atom PDF