Problem/Motivation

VBO 4.3.2 and Drupal 11.

I need to show a custom action to a specific role.

In the module readme it is not mentioned, but in this guide it is mentioned that you can use the "requirements" to show the action to a given permission, this does not work for me.

requirements: an array of requirements that must be met to make the action available. Possible options:
_permission - if user has that permission, the action will be displayed in the options select list.
_custom_access - if set to TRUE, action's customAccess method will be called to determine if the current user can run the action on a specific object/ entity (see ViewsBulkOperationsActionBase for a default implementation). If FALSE or not defined, the customAccess method will not be called.

This is my plugin annotation.

/**
 * Action description.
 *
 * @Action(
 *   id = "generate_x_report",
 *   label = @Translation("Generate the report"),
 *   type = "",
 *   requirements = {
 *     "_permission" = "permission to generate x report",
 *   },
 * )
 */

Users without the permission "permission to generate x report" can also see "Generate the report" option of vbo.
Am I wrong about this?
I don't know if this is a bug or the documentation is wrong.

Comments

abelpzl created an issue. See original summary.

graber’s picture

Status: Active » Needs work
Issue tags: +Needs documentation updates

API changed, you need to do the same as in Drupal\actions_permissions\EventSubscriber\ActionsPermissionsEventSubscriber::alterActions() now (actions_permissions is in views_bulk_operations/modules).
Docs need updating.

graber’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.