How can I display the private message form in a block on a content type, prepopulate and hide the To field with the node author?

Comments

berdir’s picture

Status: Active » Fixed

You should be able to find everything Privatemsg specific you need on http://drupal.org/node/624528. Note that the documentation is for 6.x and might need some slight adjustments for 7.x.

kevinquillen’s picture

Thank you. I didn't see that page. I will take a look.

kevinquillen’s picture

Here's what I have:

$recipient = user_load($vars['uid']);
$subject = 'Question about your listing';
module_load_include('pages.inc','privatemsg');
$contact = drupal_get_form('privatemsg_new', $recipient, $subject);

I can dump $contact and see a form array, but I cannot get anything to show up on the page. I tried using render(item) and drupal_render() but nothing happened. What do I need to call to display the renderable array as a themed form?

kevinquillen’s picture

Got it, forgot to use $vars['contact'].

Status: Fixed » Closed (fixed)

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

lameei’s picture

Hi Kevin
I'm trying to do the same on V6. would you please help me?

lameei’s picture

Status: Closed (fixed) » Active

Just opening the issue...

berdir’s picture

Status: Active » Closed (fixed)

Create a new issue, don't re-open long closed ones.

You can also try to ask on Drupal Answers.

lameei’s picture

ok,sorry. I didn't want to make a new issue for the same thing. anyway here is the issue i opened http://drupal.org/node/1360752.

kevinquillen’s picture

Couldn't tell you. I didn't use D6. I would assume its not too far different than what I did in #3.

lameei’s picture

And what did you mean with:

Got it, forgot to use $vars['contact'].

Would you please write me the correct code here?

kevinquillen’s picture

That's what I used in a preprocess function to populate a template variable with the private message form. You can name it anything.


$vars['contact'] = drupal_get_form('privatemsg_new', $recipient, $subject);