Limit number of upload in Imagefield depending on a specific field On my website, members can pay for 3 different offers (Gold, Silver, Bronze). I would like to limit the number of pictures a member can upload, depending on the offer he picked.

I'm using Drupal's user_form and add an "Imagefield" field, with illimited upload.
Offers are 3 taxonomy terms, and all contain a field with the max number of images allowed.

I'm able to get the amount of images allowed, from the taxonomy term, but how would i go about applying that limit to the imagefield?

Thanks a lot!
This will need customising to your specific situation, but the basic idea is to add a validation handler to the node form and perform a check in there, e.g.

function MYMODULE_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  if ($form_id == 'the_form_id') {
    $form['#validate'][] = 'MYMODULE_images_validate_limit';
  }
}

function MYMODULE_images_validate_limit($form, &amp;$form_state) {
  $images_submitted = count($form_state['values']['field_image'][LANGUAGE_NONE]);

  if ($images_submitted &gt; function_to_get_limit()) {
    form_set_error('field_image', t('Too many images'));
  }
}