Default state of new manual registrations is hard to change

Created on 31 December 2023, 6 months ago
Updated 16 January 2024, 5 months ago

Problem/Motivation

I may be missing something basic, but I've been on a bit of a mystifying journey with the default state of newly created registrations today.

I am using commerce_registration, and like the way in which that sets registrations to complete when an order is paid. But I also want staff to be able to create registrations manually, not using checkout. Which RegisterForm supports well.

However, OOTB the only state that staff can choose to have the new registration in is 'pending'. And even once they've saved it, they still can't edit the state to be anything else.

Problems

(1) This seems like an odd OOTB setup, not a great initial sitebuilder UX.

(2) I could in theory change the workflow configuration so that options like 'complete' would show up on the RegisterForm as a state option, but because of πŸ› Don't force the state and workflow on new registrations Fixed this would actually lead to bugs like the 'completed' time not being filled in properly.

I know I could enable the Registration Workflow submodule which would allow editors to change the state after first saving the registration. But this still leaves an odd OOTB experience for Registration core, and having to perform this second operation is not great UX for the staff.

Proposed resolution

I don't have a proprosed resolution, I just wanted to flag up that the OOTB experience here is a bit unexpected.

Remaining tasks

User interface changes

API changes

Data model changes

✨ Feature request
Status

Fixed

Version

3.1

Component

Registration Core

Created by

πŸ‡¬πŸ‡§United Kingdom jonathanshaw Stroud, UK

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @jonathanshaw
  • πŸ‡¬πŸ‡§United Kingdom jonathanshaw Stroud, UK

    My workaround for now is:

    /**
     * Implements hook_ENTITY_TYPE_insert().
     */
    function ahs_registration_registration_insert(\Drupal\registration\Entity\RegistrationInterface $registration) {
      // When staff create registrations not using checkout, they are always complete.
      if ($registration->getState()->id() == 'pending' && $registration->get('order_id')->isEmpty()) {
        $registration->set('state', 'complete')->save();
      }
    }

    This seems clean enough, but a bit surprising.

  • πŸ‡ΊπŸ‡ΈUnited States john.oltman

    Thanks for the post! With the related issue fixed, you should now be able to change the Completed state to "show on form" and the completed timestamp will get set properly. I am going to sleep on it but will probably address this issue by adding a note to the README indicating that sites with administrators that do manual registrations will likely need to configure additional states to show on form. I agree this is more work for site builders who have this use case, but I'm inclined to have the extra work for the use case that needs it, rather than force sites that do not have the use case to remove the show on form setting.

  • πŸ‡¬πŸ‡§United Kingdom jonathanshaw Stroud, UK

    Thanks for the fix @john.oltman!

    Adding a note to the README indicating that sites with administrators that do manual registrations will likely need to configure additional states to show on form.

    I agree that documentation may well be the answer.

    One thing I realise that I still don't know the answer to, and which might be worth documenting as a natural use case, is how one could configure it so that staff can create a 'complete' registration, but visitors can only create a 'pending' registration.

    Actually, I think this might suggest there's a feature missing: from my reading of the code, the permissions created in registration_workflow don't seem to influence what states are discovered by getStatesToShowOnForm().

  • πŸ‡ΊπŸ‡ΈUnited States john.oltman

    For the natural use case, make Pending the default state for the registration type, configure the Complete state as "show on form", and give "edit state" permission to your staff but not regular visitors. Visitor registrations will end up in Pending, while staff will see the State field - it will default to Pending but they can choose Complete. If staff should only be able to create Complete registrations and not Pending, then I'd skip the "show on form" and "edit state" configuration and simply use a hook_registration_presave to check if the logged in user is staff and if so, set the state to complete (per Drupal docs, hook_entity_type_insert is not supposed to alter the entity data and should only be used to maintain related entities).

    Your reading of the code is correct and currently the registration_workflow module only applies the permissions to its operations and not to states in the edit form. The idea is that "edit state" permission is global and gives the user access to any "show on form" states that are valid for the registration, while the workflow operations provide the granular permissioned access. So you might give "edit state" to admins, and workflow permissions to non-admin staff. I could see a use case though to have permissioned access to the initial state for new registrations, or to apply the workflow permissions to the states in the edit form. I'll have to think on that one.

    I will beef up the READMEs per the above.

  • Status changed to Fixed 6 months ago
  • πŸ‡ΊπŸ‡ΈUnited States john.oltman

    I added some minimal docs on this topic to the relevant README files. I also added a Task to add a new documentation guide that can cover this topic in detail, including the "natural use case".

  • πŸ‡¬πŸ‡§United Kingdom jonathanshaw Stroud, UK

    Nice, that all makes sense and thanks for the explanation.

    I'm using the group module so strictly speaking my definition of 'staff' needs to vary depending on the group that is being registered for, but that's a wrinkle I will worry about later!

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024