I'm using Entity Translation for node translations.

I would like to modify access to edit form for this translation language based on roles and node properties. I've a field in the node entity with a select list of languages, translator should only access translate nodes in languages that are checked in that list.

Which is the best option to modify the access to the node/{NID}/edit/{LANGUAGE} ?

  • hook_menu_alter ?
  • hook_node_access(): this hook is called but how can I get the language? ($_GET could be problematic I think).
  • Extending the EntityTranslation class?
  • Other?
  • have you found any solution. If so that will be very helpful if you can share your solution here. Thanks!
    – jas
    Commented Apr 4, 2016 at 7:40

1 Answer 1


This is how its working for me, with args() we can get path ie english or any other language node is there :

Example Paths in my case:





define('ROLE_EDITOR',4); // role ID 4
define('ROLE_EDITOR_ENGLISH',10); // role ID 10

function my_module_node_access($node,$op,$account) {
  global $user;

  if (in_array(ROLE_EDITOR, array_keys($user->roles)) && !in_array(ROLE_EDITOR_ENGLISH, array_keys($user->roles))) {
    if(arg(3)== "en"){
      return NODE_ACCESS_DENY;
    if(arg(3) == "add" && arg(4) == "sv"){
      return NODE_ACCESS_DENY;

  if (!in_array(ROLE_EDITOR, array_keys($user->roles)) && in_array(ROLE_EDITOR_ENGLISH, array_keys($user->roles))) {
    if(arg(3)== "sv" || arg(3)== NULL){  // Null is need to add as edit and edit/sv is same in my case because sv is defult language 
      return NODE_ACCESS_DENY;
    if(arg(3) == "add" && arg(4) == "en"){
      return NODE_ACCESS_DENY;


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.