I need to show the send message form with the "To" field prepopulate with the content creator username and then hidden from the user view.
Have read this and this.
The second one seems to be the solution but i couldn't print out the form.

Comments

lameei’s picture

I think Kevin have found the solution here but there is a little problem with the solution which he mentioned it there but I can not figure it out. here is the kevin's solution:

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

Kevin suggests this for the v7. This does not print the form. He says in this tread that he forgot to use $vars['contact'].
Is this gonna work on v6 too. What is the correct codes for this one?

lameei’s picture

Nothing new?

lameei’s picture

Ok, I have found a sulotion:

<?php
global $user;
module_load_include('pages.inc','privatemsg');
$args[0] = arg(1);
$node_id = $args[0];
$node = node_load($node_id);
$recipients = $node->uid;
echo drupal_get_form('privatemsg_new', $recipients, $subject);
?>

With this snippet you can create a block with containes the send a message form. the recipient field is not heddin yet.
What I'm working right now is showing the real name (which have been set up using realname module) of the author instead of the uid.

lameei’s picture

I have hide the "To" field with using CSS. I think this is not the right way to do it so please somebody help :)

lameei’s picture

Am I doing this right?

dhayles’s picture

I'm exploring how to hide the to: field completely, but if you wish it to be repopulated and disabled then try out the solution I have found here: http://drupal.org/node/790414

I created a simple 7.x module as suggested and it worked perfectly. It includes both 6.x and 7.x code

alex.87’s picture

When i add this into my node i just get array as output. Any clue? Im in d7 thou...

oadaeh’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)

This issue is being closed because it is against a branch for a version of Drupal that is no longer supported.
If you feel that this issue is still valid, feel free to re-open and update it (and any possible patch) to work with the 7.x-1.x branch (bug fixes only) or the 7.x-2.x branch.
Thank you.