I need a hook (or something similar) where I can set the number of image uploads depending of the role of the user.

In the settings of the field there is no way to set the maximum number of values users can enter, just one value for all roles. For example, for role #1 I want the users can upload just 3 images, for role #2 just 5 images.

I tried several ways but none worked. I tried using #element_validate but the validation never worked.

Is there some way to do that?

Comments

John_B’s picture

A bit of Googling points to contributed modules which may do that http://stackoverflow.com/questions/5739080/drupal-set-separate-maximum-r..., and to guidance on programming this yourself http://stackoverflow.com/questions/5701488/change-fields-number-of-value.... I have not tried any of these solutions.

Digit Professionals specialising in Drupal, WordPress & CiviCRM support for publishers in non-profit and related sectors

dialn’s picture

I'm looking for the same function someone who can give us light on the subject, would greatly appreciate your help

ElPanchito’s picture

I am trying to set limit to a image field in Drupal 8, it is unlimited but I want to change it to 1 image depending on the role. Can anyone helo me? :(

VM’s picture

you will need to review the contributed modules already mentioned in links within this thread to see if there are any D8 versions available. If not you will need to port one of those available, write your own, or pay someone to do either of the two.