0

I’ve created a new action in a custom module using hook_action_info()

/**
 * Implementation of hook_action_info().
 */
function recruiteractions_action_info() {
  return array(
    'applicationentity_recruiterfillposition' => array(
      'type' => 'application', // <-- New entity type here
      'label' => t('Application Postion Fill Action'),
      'behavior' => array('changes_property'), //<-- Triggers an entity save.
      'configurable' => FALSE,
      'vbo_configurable' => FALSE,
      'triggers' => array('any'),
    ),
  );
}
function applicationentity_recruiterfillposition(&$entity, $context = array()) {
  $app_wrapper = entity_metadata_wrapper('application', $entity);

 $app_wrapper->field_job_status->set(‘1');
 $app_wrapper->save();

}

After enabling in VBO this all works fine and as it should. The issue being when i set this to the role I need it to be set on.

the ‘Actions permissions (VBO) module is activated. and I can see the action; and have ticked the roles needed but with no joy.

I’ve also checked the ‘field_job_status’ permissions for the role I wish to allow to make changes.

On Drupal hook_action_info page https://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_action_info/7 there is a post regarding 'behavior's impact on permissions and specifically mentions VBO. however I'm not sure on what I need to do. Has anyone got any examples for this.

1 Answer 1

2

The solution here was to set the permission I want in the access_callback of the custom entity itself.

so in my case the hook_entity_info

'access callback' => 'myentity_access_callback',

then added this in a function

function myentity_access_callback($roles = array()) {  // $op, $application = NULL, $account = NULL
 global $user;
 $roles = array(
   'administrator', 'anotheradminrole', 
 );
  foreach ($roles as $role) {
    if (in_array($role, $user->roles)) {
      return TRUE;
    }
  }
  return FALSE; 
}

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.