2

I have a content type: Test I want to alter the permission to translate it based on one of it's field value. Take the following use-case (field type, and role doesn't matter):

If field_test == '1' then the Translate link task should not be displayed (because the current user role does not have permission to view it).

What do you suggest?

3
  • 1
    Hi, what type of field is fielt_test ? Taxonomy term reference, boolean checkbox or select list or simply text field? Commented Mar 20, 2017 at 10:13
  • 1
    Furthermore, what roles do you have in your website ? Could you please post all of this to the quesiton description ? Commented Mar 20, 2017 at 10:14
  • 1
    Field type and role doesn't matter in this question. I just want to find the right place where I can put my own business logic
    – ssibal
    Commented Mar 20, 2017 at 10:23

2 Answers 2

3

I think something like that already has been answered before:

Could you take a look and tell us if that helps you ?

https://drupal.stackexchange.com/a/208817/8375

Other outside resources: https://www.previousnext.com.au/blog/controlling-access-drupal-8-routes-access-checks

3
  • 1
    The first link is a good help (however I didn't used that). The second one is outdated! I think that should be removed!
    – ssibal
    Commented Mar 20, 2017 at 17:39
  • 1
    would you mind posting the code that helped you, because i am also looking for solution Commented Mar 20, 2017 at 18:25
  • 1
    It just posted it after yours!
    – ssibal
    Commented Mar 21, 2017 at 8:48
2

For me this official link helped:

About route alteration: https://www.drupal.org/docs/8/api/routing-system/altering-existing-routes-and-adding-new-routes-based-on-dynamic-ones

About access check: https://www.drupal.org/docs/8/api/routing-system/access-checking-on-routes

@Oleg Videnov: The first link you provided in your answer is good as well!

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.