1 taxonomy.module taxonomy_term_access($op, $term)

Access callback: Checks a user's permission for performing a taxonomy term operation.

@since 1.13.0 The "create" and "view" $op options were added. @since 1.13.0 The "edit" $op option is deprecated. Use "update" instead.

Parameters

string $op: The operation to be performed on the taxonomy term. Possible values are:

  • create
  • view
  • update
  • delete

TaxonomyTerm|string $term: The $term object on which the operation is to be performed, or the vocabulary for the 'create' operation.

Return value

TRUE if the operation may be performed, FALSE otherwise.:

See also

taxonomy_menu()

File

core/modules/taxonomy/taxonomy.module, line 560
Enables the organization of content into categories.

Code

function taxonomy_term_access($op, $term) {
  if ($op == 'edit') {
    // Normalize edit op to update.
    $op = 'update';
    // Log to watchdog for DX. @todo add watchdog_deprecated_parameter().
    $message = 'The function taxonomy_term_access() was called with the operation <em>edit</em>. This operation is now named <em>update</em>. The <em>edit</em> operation will be removed in the next major release of Backdrop.';
    $variables = array();
    watchdog('taxonomy', $message, $variables, WATCHDOG_DEPRECATED);
  }

  if ($op == 'create') {
    // In some cases a TaxonomyTerm object, rather than a vocabulary string is
    // provided.
    if (is_string($term)) {
      $bundle = $term;
    }
    else {
      $bundle = $term->bundle();
    }
    return TaxonomyTerm::createAccess($bundle);
  }
  elseif ($term instanceof TaxonomyTerm) {
    return $term->access($op);
  }
  return FALSE;
}