Privatemsg allows Drupal users sending message to each other. It is a must-have feature of community oriented websites. The module includes all necessary features including inbox, outbox, user block list etc. In my case, i want to render the send message form on the user profile page. So i created a block which generate the send message form by PHP code and attached it to the user profile page. Here you are.
<?php // Load the module module_load_include('pages.inc','privatemsg'); // We could get the user id from arg(1) becoz this block is shown in profile page. $recipients = array(user_load(arg(1))); $subject = 'Hello ' . $recipients[0]->name; print drupal_render(drupal_get_form('privatemsg_new', arg(1), $subject)); // Restore the page title drupal_set_title($recipients[0]->name); ?>
Please note that drupal_get_form() returns a render array in Drupal 7, you need to use drupal_render() to convert it to a string that you can print. And i also need to reset the title to username becoz the privatemsg_new form will override the page title.
Done =)
Reference:
Can we make individual message thread auto refresh after x time interval so it can be look like chat.
LikeLike
you can try to refresh the content by ajax in regular interval, but probably that will overwhelm the server as there would be many requests.
Currently, there is no mature module for IM in Drupal. Maybe you could consider the following 3rd party codes.
IntraMessenger
LikeLike
Hello, is there a way to render list of all dialogs like on all messages tab?
LikeLike
Oh, sorry, i just forgot include module in my code…
So that’s the way:
LikeLike