2

I am trying to append a variable on the URL through a custom submit function. Is that possible?

My issue is that I am coming to the node/%/delete from different pages. I want to modify the delete form if the user comes to it from the node/%/edit. How can I detect this?

As @Clive suggested I'll try to add a query param in the following structure:

actions (Array, 5 elements)
  #type (String, 7 characters ) actions
  submit (Array, 5 elements)
  preview (Array, 5 elements)
  delete (Array, 4 elements)
    #type (String, 6 characters ) submit
    #value (String, 6 characters ) Delete
    #weight (Integer) 15
  • 1
    Don't - basing logic on referrers is hit and miss and violates a RESTful web...instead, alter the edit form and change the url of the delete link to add a URL parameter to the delete URL, then alter the delete form to check for that parameter – Clive Jun 27 '14 at 11:27
  • Awesome input!How can I do that? – Potney Switters Jun 27 '14 at 11:28
  • hook_form_alter for both, the delete link is in $form['actions'] I think. Just on mobile so can't put code samples in I'm afraid – Clive Jun 27 '14 at 11:31
  • Cool!How could I add the param on the above structure? – Potney Switters Jun 27 '14 at 11:35
  • @Clive can you explain it more, I couldn't understand, as far as I know pressing delete button from node edit form will take you to a confirmation page, which is a redirect, and nothing will be passed on to that page other than node id and destination. – wolverine Jun 27 '14 at 12:12
0

You should use the hook_node_access in your custom module.

For Example -

/**
 * Implements hook_node_access().
 */
function MODULE_node_access($node, $op, $account) {

  if ($op == "delete") {
    // If no user object is supplied, the access check is for the current user.
    if (empty($account)) {
      $account = $GLOBALS['user'];
    }
    // You can add your own condition check here...
    return user_access("delete content", $account) ? NODE_ACCESS_ALLOW : NODE_ACCESS_DENY;
  }

  return NODE_ACCESS_IGNORE;

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.