0

I have a view containing saved user webform drafts set up in a table format. I have given permission to the authenticated user to delete own submissions. When clicking the delete link located on the table it redirects user to a separate page asking "Are you sure you want to delete this submission?" I'd like to accomplish one of two things.

  1. Have no delete confirmation, when the user clicks delete it is immediately deleted. Preferred

  2. Have the delete confirmation page as a pop up.

I'm new to coding drupal modules but I believe I have isolated the code to be found within the webform.submissions.inc folder, line 465 - 467:

$question = t('Are you sure you want to delete this submission?');

return confirm_form($form, NULL, "node/{$node->nid}/submission/{$submission->sid}", $question, t('Delete'), t('Cancel'));

Any help would be appreciated, I have searched and researched and keep coming to the same results.

1 Answer 1

0

Use the hook_form_alter hook, check which form you're on and what the current action is, then remove the node and redirect to where you want to go.

https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_form_alter/7.x

Here's my D8 code, should be fairly similar in D7:

<?php

function my_module_name_form_alter(&$form, $form_state, $form_id)
{
  if ($form_id == 'node_mynodename_delete_form') {
    // write code here to delete the node and redirect
  }
}

This code goes into the .module file.

Replace my_module_name with the name of your own custom module.

Replace mynodename with the machine name of your node.

There are plenty of examples out there on how to programmatically remove a node and redirect.

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.