You are here

function hook_filefield_sources_sources_alter in FileField Sources 7

Same name and namespace in other branches
  1. 8 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 68
This file documents hooks provided by the FileField Sources module. Note that none of this code is executed by using FileField Sources module, it is provided here for reference as an example how to implement these hooks in your own 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]);
    }
  }
}