Call node edit form

Public

This can be used to show a node edit form for an anonymous user.

Get raw version
php
  1. // Assume 'node_edit_demo' is the form id of your node form
  2.  
  3. /**
  4.  * Implements hook_menu()
  5.  */
  6. function modulename_menu() {
  7.  
  8. $items['node-edit/%'] = array(
  9. 'title' => t('Node Edit Form'),
  10. 'page callback' => 'custom_call_node_edit',
  11.  
  12. // this ensures file field proper functionality on node edit form
  13. 'file path' => drupal_get_path('module', 'node'),
  14. 'file' => 'node.pages.inc',
  15.  
  16. // passing the nid as the page argument
  17. 'page arguments' => array(1),
  18. 'access arguments' => array('access content'),
  19. );
  20.  
  21. return $items;
  22. }
  23.  
  24. /**
  25.  * Page Callaback for hook_menu()
  26.  *
  27.  */
  28.  
  29. function custom_call_node_edit($nid) {
  30.  
  31. // $nid is the nid for the node you want to open in edit form
  32. $node = node_load($nid);
  33. module_load_include('inc', 'node', 'node.pages');
  34. $form = drupal_get_form('node_edit_demo', $node);
  35. return render($form);
  36. }