- 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.
-
john.oltman β
committed 94639c63 on 3.1.x
Issue #3411498: Document settings related to registration state
-
john.oltman β
committed 94639c63 on 3.1.x
- Status changed to Fixed
6 months ago 5:38pm 1 January 2024 - πΊπΈ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.