Score:0

How do I display only the "View" tab for a specific webform and role?

us flag

I have multiple webforms, In each of these webform submission results page I require only view page, when a non admin user uses the site to see the results, they should only see the view tab and the table, how do I unset the "Edit" tab in primary local task/tab for a specific user role and specific form and only display view tab in primary task and table in secondary local task. I did try with Tabtamer module although it provides me the options, I cannot disable the edit button for specific webforms for a role.

function custom_module_menu_local_tasks_alter(&$data, $route_name) {
  $roles = \Drupal::currentUser()->getRoles();
  $current_path = \Drupal::service('path.current')->getPath();
  if (in_array("new_user", $roles)) {
    unset($data['tabs'][0]['entity.webform_submission.edit_form']);
  }
}

The above code removes all the tabs. How do I display only the View tab for a specific webform and role?

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.