function hook_filefield_sources_sources_alter in FileField Sources 8
Same name and namespace in other branches
- 7 filefield_sources.api.php \hook_filefield_sources_sources_alter()
Allows altering the sources available on a field.
This hook allows other modules to modify the sources available to a user.
Parameters
array $sources: List of filefiled sources plugins.
mixed $context: Contains 'enabled_sources', 'element', 'form_state'.
1 invocation of hook_filefield_sources_sources_alter()
- filefield_sources_field_process in ./filefield_sources.module 
- A #process callback to extend the filefield_widget element type.
File
- ./filefield_sources.api.php, line 36 
- This file documents hooks provided by the FileField Sources module.
Code
function hook_filefield_sources_sources_alter(&$sources, $context) {
  // This example will exclude sources the user doesn't have access to.
  foreach (array_keys($sources) as $type) {
    if (!user_access("use {$type} filefield source")) {
      unset($sources[$type]);
    }
  }
}