Remove Permissions by term on non node forms

Created on 5 August 2019, about 5 years ago
Updated 13 April 2023, over 1 year ago

Hi Team,

I have enabled permissions by term module in my project. I have enabled this for vocabulary called "Role based access". It is work fine.

Problem/motivation

  1. It is showing the vertical tab on node add/edit forms in all the content type.
  2. Also permissions by term element is added to all the forms (like comment form) while it comment form is showing on node details page. It is because of below code
function isNodeEditForm() {
  $currentPath = \Drupal::service('path.current')->getPath();
  if (is_numeric(strpos($currentPath, '/node/'))
    && (is_numeric(strpos($currentPath, '/edit')) || is_numeric(strpos($currentPath, '/add')))) {
    return TRUE;
  }
  return FALSE;
}

Solutions
We have to give configuration to select the which are the content type to affect the permissions by term.
We need to change the above code to only affect on the node add/edit forms. Use below code to fix this problem.

if ($form_state->getFormObject() instanceof \Drupal\Core\Entity\EntityFormInterface) {
  $entity_type = $form_state->getFormObject()->getEntity()->getEntityTypeId();
}

Thanks

🐛 Bug report
Status

Closed: outdated

Version

2.10

Component

Code

Created by

🇮🇳India iyyappan.govind Chennai, India

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024