VBO add userpoint action

function modulename_action_info() {
  return array(
    'modulename_adduserpoint_action' => array(
      'type' => 'user',
      'label' => t('userpoint operations'),
      'configurable' => TRUE,
      'triggers' => array('user_update'),
    ),
  );
}
 
function modulename_views_bulk_operations_form_alter(&$form, &$form_state, $vbo) {
  if ($form_state['step'] == 'views_bulk_operations_confirm_form' && $form_state['operation']->operationId == 'action::modulename_adduserpoint_action') {
    $form['desc'] = array (
      '#markup' => 'Action : Add userpoints ' . $form_state['operation']->formOptions['add_userpoint'] ,
    );
  }
}
 
function modulename_adduserpoint_action_form ($context) {
  $options = array();
  $options = array (
    'add' => 'Add userpoint',
    'substract' => 'Substract userpoint',
    'modifiy' => 'Fixed value'
  );
  $form['userpoint_operations'] = array (
    '#type' => 'select',
    '#required' => true,
    '#options' => $options,
  );
  $form['modulename_adduserpoint'] = array (
    '#type' => 'textfield',
    '#required' => true,
    '#title' => 'Userpoints value',
  );
  return $form;
}
 
function modulename_adduserpoint_action_submit ($form, $form_state) {
  return array (
    'add_userpoint' => check_plain($form_state['values']['modulename_adduserpoint'])
  );
}
 
function modulename_adduserpoint_action(&$user, $context = array()) {
  if (is_numeric ($user->uid)) {
    userpoints_userpointsapi(
      array(
        'uid' => $user->uid,
        'points' => $context['add_userpoint'],
        'moderate' => variable_get('userpoints_votingapi_moderation', 0),
        'event' => 'coupon',
        'entity_id' => $user->uid, 
        'entity_type' => 'user',
        'operation' => t('Add userpoint'),    
        'tid' => variable_get('userpoints_votingapi_tid', 0),  
        'description' => t('Add userpoint: !entity_type !entity_id.', array('!entity_type' => 'user', '!entity_id' => $user->uid)),    
      )
    );
  }
}
Help Share this Article