Module to restrict access from anonymous and regular users to configured pre-defined pages.
Into the /admin/config/pages_restriction/restrict_access configuration page it's possible to setup custom rules to provide access restriction for anonymous and regular users.
Was setup a custom session id to each form rule so we check if the page that user must be redirected depending on user's registering sequence.

Example: homepage|about-us will block access to about-us page and redirect users to homepage.

To possible use the current session id to enable access for multiple pages we need to setup into the form submission the function _pages_restriction_set_next_page_path($next_page_path) where $next_page_path variable should be the current_path();

Example: homepage|about-us|contact|thank-you-page

If you try to access directly the Thank you page without fill all the forms flows and without setup the set_next_page_path() into the previous pages form submit, ("About Us"), ("Contact"), you should be redirected back to the Homepage.

Author: Vitor Grillo

Drupal 8

There is a field to configure your paths using key|value syntax.

You can also configure the roles you want to bypass as the image below:

Bypass

To ignore a path at runtime you can add a bypass with the setBypass function:

\Drupal::service('pages_restriction.session_service')->setBypass($path);

Or if you prefer you can set the "pages_restriction_bypass" session manually. E.g:

$pagesRestrictionBypass[] = $path;
$this->session->set('pages_restriction_bypass', $pagesRestrictionBypass);

Credits

CI&T

http://www.ciandt.com

Supporting organizations: 
Development and Bugfixes

Project information

Downloads