The user creation form behavior has changed since 4.7. Now if you submit a user, you are returned to the create user form with form values still filled in!

Attached patch tries to set things back as they were in 4.7- normally redirect to the user admin screen.

CommentFileSizeAuthor
user_register_destination_0.diff2.52 KBpwolanin

Comments

pwolanin’s picture

Status: Active » Needs review

setting status

webchick’s picture

Status: Needs review » Needs work

Hey, that was my patch that changed that behaviour. :P I like it the way it is because you can add multiple users at once more easily, and because it is consistent with how terms and other things in Drupal are added.

The pre-populating of username and email with old values when directed back to admin/user/user/create is a new thing though, is definitely a bug, and should be taken out. Marking code needs work, as that problem should be addressed instead.

webchick’s picture

Status: Needs work » Closed (won't fix)

Oh, looks like there is already an issue for this bug: http://drupal.org/node/79804

Marking as won't fix.

webchick’s picture

Status: Closed (won't fix) » Closed (duplicate)

Re-classifying.

Observed behaviour is caused by http://drupal.org/node/79614. Marking as a duplicate.

pwolanin’s picture

Status: Closed (duplicate) » Needs review

I don't think this is a duplicate. The problem occurs on the user creation form, not the login form. The referenced patch seems to fix the problem of the form values remianing, but not of going back to the user creation form itself.

At the very least, the lines:

    // Redirect back to page which initiated the create request; usually admin/user/user/create
    $form['destination'] = array('#type' => 'hidden', '#value' => $_GET['q']);

seem to need to be removed (or changed) since if this redirect was desireable, by looking at form.inc the proper element would be $form['#redirect'].

drumm’s picture

Status: Needs review » Needs work

It looks like this patch changes the page which we redirect to for both admin registrations and self-registrations.

For admins-
I think we should redirect to the user listing page because that shows that the new user has been created and is in the list. The only place we redirect to the same form that was just filled out that I can think of is taxonomy terms, so I don't think there is an established convention for this behavior. We also need to look at how frequently people add one user vs. adding multiple users. My rough and not-supported-by-data guess is that the singletons happen more.

For self-registrations-
The next step for the user is (hopefully) logging in using the information provided via email. The user should be at the login form. It looks like it goes to the front page in this patch.

webchick’s picture

FWIW, here's the original issue:
http://drupal.org/node/62855

I set destination per Moshe, as he brought up a good point about calling the registration part from external modules.

As long as the bloody form doesn't redirect back to the user list everytime you add a new user, though I'm cool with whichever. :P

webchick’s picture

Adding multiple users from the admin panel happens more often than you'd think, for example:

1. When you want to add your fellow development team members to a site you're working on.
2. When you're testing a site (or testing patches), and want to quickly make a few users: one with 'normal' permissions, one with role X, one with role Y, etc.
3. When you have site registrations closed, you need to add *all* members to the site this way.

The "singleton" case seems to be going through the actual user registration form. I'm having a difficult time figuring out when you would just add one user, unless your site was extremely small.

So I'd prefer to see this "fixed" in one of two ways:

1. A more descriptive drupal_set_message that says, "User account bob was created. No e-mail was sent."
2. A checkbox on this form that basically says, "Add another user" and, if set, will return to this form.

pwolanin’s picture

Version: x.y.z » 6.x-dev
Status: Needs work » Closed (duplicate)

I thnik webchick got a patch in to make the message link to the created user.

tommo’s picture

Could you explain to me the difference between:
$form['destination'], $form['#action'] and $form['#redirect'] ?

I've been setting the #redirect for most forms but I can not get it to work in the 'user_register' form and my modules have to edit the $form['destination'] field for it to work.

What should be the most appropriate method?

(supplied with enough info on the differences between the fields I will create a handbook guide on 'redirecting forms correctly' as I beleive this topic to be quite vague)

nosro’s picture

Title: user creation form should redirect to admin/user/user » handbook on redirecting forms

That would be great if you get enough info to create a handbook page. I have been having trouble redirecting from the user registration form. I'll try the $form['destination'] now.

nosro’s picture

Title: handbook on redirecting forms » user creation form should redirect to admin/user/user