0

I'm lost on how to do this. I need guest users to have the form fully validated (using the client side validation module) upon creation, but not validating for an authenticated user.

tldr;

The customer (always a guest) will be able to place an order for pickup on a particular date, that date cannot be earlier than 5 days from "today". The customer must always obey the validation rules. Easy, these are set up and working.

When a staff member (always an authenticated user) places a phone order for a customer, they need to be able to override that date, even to one less than 5 days out, skipping the validation.

Similarly, when the staff member edits/updates the webform, they need to be able to do so when it's less than the 5 days. The current client side validation module prohibits anyone from editing the form in less than five days, unless I have the date hidden from them.

I'm struggling to find a process or module that will make this work. Any ideas?

1 Answer 1

0

The simplest thing is to apply the validation as you normally would, and then write a hook_form_alter() that does the following:

  1. Determine if the current user is logged in, or has a particular role.
  2. If logged in, remove the validation pieces from the form render array of that particular field.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.