when calling privatemsg_new in a block, how can I correctly set the internal $destination variable? I am calling privatemsg_new in php in a block so that the form to contact the node author is on the same page as the content. here is the code.

$node = menu_get_object();
if ($node-&gt;uid != 0) {
module_load_include('pages.inc','privatemsg');
$recipients = $node-&gt;uid;
print "&lt;div&gt;Contact " . $node-&gt;name ." about this post.&lt;/div&gt;";
$subject = $node-&gt;title ." question.";
print drupal_render(drupal_get_form('privatemsg_new', $recipients, $subject));


Normally you access this form from the node page via a link that reads 'send this author a message' and that link loads a 'destination' parameter into the url query so that, when the message is finished, it redirects you back to the node page.

My code for the form in the block works fine except for the redirection back to the page after submission.  The variable that needs to be set is inside the scope of the privatemsg_new function:

http://drupalcontrib.org/api/drupal/contributions!privatemsg!privatemsg.pages.inc/function/privatemsg_new/7

How can I set that variable so that redirection works correctly?

EDIT 8/1/2012
Eugene's answer below was the correct direction and code for this particular problem, but I wanted to update my question with the exact code necessary to achieve a fully functioning 'Contact Author' block.  Simply copy and paste this in for Drupal 7 and it should work great, if you looking for the same solution.

$node = menu_get_object();
if ($node-&gt;uid != 0) {
module_load_include('pages.inc','privatemsg');
$recipients = $node-&gt;uid;
print "&lt;div&gt;Contact " . $node-&gt;name ." about this post.&lt;/div&gt;";
$subject = $node-&gt;title ." question.";
$form = drupal_get_form('privatemsg_new', $recipients, $subject);
// Setup destination parameter to be equal to current page.
$form['#action'] = url('messages/new/'. $node-&gt;uid, array ('query' =&gt;    drupal_get_destination()));
  print drupal_render($form);
drupal_set_title($node-&gt;title);
}


You have to set the drupal title manually. The reason being that the privatemsg_new function overrides this.
Try this code in block, if you don't want to implement any hook in custom module.

$node = menu_get_object();
if ($node-&gt;uid != 0) {
  module_load_include('pages.inc','privatemsg');
  $recipients = $node-&gt;uid;
  print "&lt;div&gt;Contact " . $node-&gt;name ." about this post.&lt;/div&gt;";
  $subject = $node-&gt;title ." question.";
  $form = drupal_get_form('privatemsg_new', $recipients, $subject)
  // Setup destination parameter to be equal to current page.
  $form['#action'] = url('node/'. $node-&gt;uid, array ('query' =&gt; drupal_get_destination()));
  print drupal_render($form);
}