Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By jdeg on
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
A bit of Googling points to
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
I'm looking for the same any help
I'm looking for the same function someone who can give us light on the subject, would greatly appreciate your help
Set limit image Drupal 8
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? :(
=-=
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.