How to customize the confirmation screen

Created on 19 June 2012, almost 13 years ago
Updated 27 March 2025, 11 days ago

I have created a custom action to assign users to organic groups using the functions:

function ccn_groups_action_info() {
return array(
'bulk_group_assignment_action' => array(
'type' => 'user',
'label' => t('Assign Users to Groups'),
'configurable' => TRUE,
),
);
}
function bulk_group_assignment_action_form($context) {
$roles = array();
$e_type = 'node';
$results = db_query("select gid, label from og where entity_type = :e_type order by label",
array(':e_type' => $e_type,),
array('fetch' => PDO::FETCH_ASSOC,));
foreach ($results as $row){
$roles[$row['gid']] = $row['label'];
}
$form['add_roles'] = array(
'#type' => 'select',
'#multiple' => TRUE,
'#title' => t('Available Groups'),
'#description' => t('Choose one or more groups you would like to assign to the selected users.'),
'#options' => $roles,
'#size' => 20
);
return $form;
}
function bulk_group_assignment_action_validate($form, $form_state) {
if (!$form_state['values']['add_roles'] ) {
form_set_error('add_roles', t('You have not chosen any group to add. Please select something to do.'));
}
}
function bulk_group_assignment_action_submit($form, $form_state) {
return array(
'add_roles' => array_filter($form_state['values']['add_roles']),
);
}

function bulk_group_assignment_action(&$user, $context) {
$usr = $context['user'];
$roles = $context['add_roles'];
$uid = $usr->uid;
$name = "og_membership_type_default";
$etid = $uid; //Supplied from $context
$entity_type = "user";
$gid = "666"; //Supplied from $context
$state = 1;
$created = time();
foreach($context['add_roles'] as $gid){
$nid = db_insert('og_membership')
->fields(array(
'name' => $name,
'etid' => $etid,
'entity_type' => $entity_type,
'gid' => $gid,
'state' => $state,
'created' => $created,
))
->execute();
}
}

These functions work as expected, providing a form where the user can select 1 or more groups, along with a view where the user can select users to assign to the selected groups. Additionally the user performing the operation receives a warning if no groups are selected or if no users are selected.

And finally, before performing the operation, the user performing the operation receives a confirmation page listing the users selected for assignment.

Once completed the user receives a message indicating that the operation has bee performed for n number of items.

Clients being clients want something different on the confirmation page and on the post-processing message. Specifically, on the confirmation page, the client wants to see the groups selected as well as the users selected, and on the post-processing page wants to see the number of the groups to which the users were assigned.

Despite hours upon hours of research including examination of the VBO code itself (where I found the code that produces the confirmation page and the post processing message, I've been unable to determine any way to modify the confirmation message or the post processing page.

Any thoughts or pointers would be greatly appreciated!

πŸ’¬ Support request
Status

Fixed

Component

Actions

Created by

πŸ‡ΊπŸ‡ΈUnited States deastlack

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.

  • I came across this post while searching for D10, so I’d like to share my issue and solution.

    Issue: When upgrading from Drupal 10.2 to Drupal 10.3, the original confirmation page did not work, and it submitted directly.

    Solution: In the plugin action annotation, change confirm = TRUE to confirm_form_route_name = "my_module.my_special_action_confirm_form". Since I only need the confirmation page and do not require custom confirmation content, I directly used the confirmation page from Views Bulk Operations: confirm_form_route_name = "views_bulk_operations.confirm".

    /**
     * xxx
     *
     * @Action(
     *   id = "views_bulk_operations_xxx",
     *   label = @Translation("XXX"),
     *   type = "",
     *   confirm_form_route_name = "views_bulk_operations.confirm",
     * )
     */
    
Production build 0.71.5 2024