Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Usage Milestone: Google Analytics Module google_analytics crossed 1,000 active installs. Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Release: GraphQL Compose Codegen 1.1.2 Minor update available for module graphql_compose_codegen (1.1.2). Release: Mapy.com 1.1.3 Minor update available for module mapycom (1.1.3). Release: Ckeditor5 entity browser 3.0.3 Minor update available for module ckeditor5_entity_browser (3.0.3). Release: Ckeditor5 entity browser 3.0.1 Minor update available for module ckeditor5_entity_browser (3.0.1). Release: Ckeditor5 entity browser 3.0.2 Minor update available for module ckeditor5_entity_browser (3.0.2). Release: Teamleader Integration 4.0.2 Minor update available for module teamleader (4.0.2). Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

Views Access Conditions

366 sites Security covered Drupal 10–11 Views ecosystem
View on drupal.org

This module allows you to control access to views based on configurable conditions. It also enables controlling the visibility of fields and filters within views based on these conditions. This is particularly useful for multi-site setups or shared codebases where sites need differentiated access to views.

A Drupal module that allows you to control access to views based on configurable conditions.

Overview

Views Access Conditions provides a flexible way to control when views are accessible on your Drupal site. This module extends Drupal's views access plugin system to include conditional rules, making it easy to control access to views based on various conditions.

In version 2.1+ users can also control what fields and filters are visible in their views based on conditions. Contextual filters can be enabled/disabled based on conditions as well.

But why?

The benefit of this approach is for multi-sites, or shared codebase platforms, that share configuration across multiple sites but want some flexibility in control of when views are accessible. For example, if there are two sites sharing the same codebase, Site A and Site B, and only Site B needs a particular view to be accessible then using views access plugins, we are able to configure access based on a condition - this could be one provided by core, the contrib space, or something custom. This way both sites can still share the same configuration, as the access conditions are stored in config, but the conditions are evaluated per-site.

Requirements

- Views

Installation

1. Download the module:
You can download the module using Composer:

composer require drupal/views_access_conditions

2. Enable the module:
After downloading, enable the module using Drush or the Drupal admin interface:

drush en views_access_conditions

Or, enable it through the admin interface at /admin/modules.

Configuration

The module offers a settings page to configure which conditions are available for use with restricting views access.

Usage

1. Navigate to edit a view
2. Look for the "Access" section
3. Select Conditions
4. Add one or more conditions that determine when the view should be accessibled
5. Save the view configuration

Extending the module

Developers can alter the available conditions using the provided hook:

/**
 * Implements hook_views_access_conditions_available_conditions_alter().
 */
function hook_views_access_conditions_available_conditions_alter(array &$conditions, ?FormStateInterface $form_state = NULL, ?string $form_id = NULL): void {
  // Remove specific conditions
  $conditions_to_remove = [
    'language',
    'request_path',
  ];
  $conditions = array_diff_key($conditions, array_flip($conditions_to_remove));
}

Contributing

Contributions are welcome! If you would like to contribute to this module, please follow these steps:

1. Open an issue on the issue tracker
2. Create a Merge Request or add a patch
3. Mark your issue as Needs Review.

License

This module is licensed under the GPL-2.0+ license.

Maintainers

- Owen Bush

Depends on

Dependencies of the latest stable release

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
7
Tracked since
Apr 2025
Latest release
6 months ago
Releases (12 mo)
1 ▼ from 6
Maintenance
Slowing

Release Timeline

Releases

Version Type Core Release date
2.1.2 Stable 10–11 Feb 6, 2026
2.1.1 Stable 10–11 Jun 18, 2025
2.1.0 Stable 10–11 Jun 18, 2025
2.0.0 Stable 10–11 May 19, 2025
1.1.0 Stable 10–11 May 9, 2025
1.0.1 Stable 10–11 Apr 15, 2025
1.0.0 Stable 10–11 Apr 14, 2025