Instead of using $_GET, and hacking in to the '/new' form, it makes more sense to provide another menu callback and wrapping around the privatemsg form.

To do this:

  1. Add an additional menu item with a path of $url_prefix . '/drafts/%privatemsg_drafts_draft'
  2. Add an access callback that validates that the current user is allowed to access that draft. This is another way to resolve #1260164: Users can probably load drafts they don't own, and probably better now that I think about it. You'll also be able to get rid of the drupal_access_denied() hack you currently have in your form alter.
  3. Add a loader function with the signature "function privatemsg_drafts_draft_load($draft_id)".
  4. Create a new page callback that takes a draft as an argument. It will call drupal_get_form('privatemsg_drafts_draft');
  5. The privatemsg_drafts_draft() function will call privatemsg_form_new() or privatemsg_form_reply() directly, without using drupal_get_form(). That will allow you to modify it's returned $form array as needed. Since the form is using #submit (yay!) you should be able to chain on your own submit handler to delete the draft when the message is sent.

Comments

deviantintegral’s picture

Just noticed hook_privatemsg_message_insert(), so you can ignore my comment about #submit.

chrisfree’s picture

Status: Active » Fixed
chrisfree’s picture

Status: Fixed » Active
chrisfree’s picture

Status: Active » Fixed

Marking as fixed for now. My only concern is with the draft edit page for "reply" drafts. Calling "privatemsg_form_reply()" directly is great, except that it doesn't render the entire thread that the user is responding to. So the reply draft doesn't really have much context. For now, I've added a simple link back to the thread. I'll consider this a to-do for later.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.