New answers tagged

0

The entity.user.canonical route has one parameter, $user. Route parameters can be retrieved from the route object and are upcast to their respective object. So, the user id will be upcast to the user object. This technique is explained for nodes in the question How do I get the current node ID, but you can do the exact same thing with users. For example: $...


-1

If you look into ParagraphAccessControlHandler you will find something similar. Implement something similar in your Access callback. protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL) { // Allow paragraph entities to be created in the context of entity forms. if (\Drupal::requestStack() ->...


0

Take a look at Redirect 403 to User Login module can help you.


0

function THEME_preprocess_page(&$variables) { global $base_url; $is_anonymous = \Drupal::currentUser()->isAnonymous(); $route_name = \Drupal::routeMatch()->getRouteName(); $is_not_login = $route_name != 'user.login'; if ($is_anonymous && $route_name == 'system.403' && $is_not_login) { $response = new RedirectResponse( $base_url . '/...


0

I've created a module and is busy adding it to Drupal site. The code is available here for download. https://github.com/hornlp/drupal_path_guard The intended use of the module is to redirect GUEST / ANONYMOUS users when they access content in Drupal using URL /node/{id}. Many sites make use of URL ALIAS and don't want users necessarily to scan content out of ...


Top 50 recent answers are included