Link to "New Message" from profile page
McGo - July 22, 2008 - 17:07
| Project: | Privatemsg |
| Version: | HEAD |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | patch (code needs work) |
Jump to:
Description
I want to create a link that says "Send this user a new message". So I have to call a url like messages/private/new/4711 where 4711 is the uid of the receipient. Currently this is not possible.

#1
#2
Not sure about the best way to do this, but I do have a working version:
In the menu code add:
<?php$items['user/%user/message'] = array(
'title' => 'Send Message',
'page callback' => 'drupal_get_form',
'page arguments' => array('privatemsg_new'),
'access arguments' => array('write privatemsg'),
'type' => MENU_LOCAL_TASK,
);
?>
and then in privatemsg_new replace
<?php$recipient = '';
?>
with
<?phpif (arg(1) == 'new') {
$recipient = '';
}
else {
$user = user_load(arg(1));
$recipient = $user->name;
}
?>
I have not added as a patch because it is not pretty. But it does work, but a little differently from the asked for solution:
1. a user's profile page will contain a tab called "Send Message". This goes to user/uid/message, where the recipient is autofilled in.
2. However, this also adds a tab to a user's own page too, so a user can itself a message this way. Some may like this, but I consider it a bug.
#3
#4
Commited to HEAD
#5
This does not have any access checks.
Viewing the profile page shows the link to send a new message even if the user does not have permission (only after clicking the link will the user realise the lack of permission - with the access denied message.)