I thing that if i'm in my user page i shouldnt see the link : "Send this user a private message"

so here the "privatemsg_user_view" function edited:

function privatemsg_user_view($account) {
global $user;
if ($account->uid != $user->uid){
  if (($url = privatemsg_get_link(array($account))) && variable_get('privatemsg_display_profile_links', 1)) {
    $account->content['privatemsg_send_new_message'] = array(
      '#type'   => 'link',
      '#title'  => t('Send this user a private message'),
      '#href'  => $url,
      '#weight' => 10,
      '#options' => array(
        'query' => drupal_get_destination(),
        'title' => t('Send this user a private message'),
        'attributes' => array('class' => 'privatemsg-send-link privatemsg-send-link-profile'),
      ),
    );
  }
}
}

Basically if the page author is the user uid, hide the form.
Hope this helps!
Bless

Comments

jasom’s picture

I agree, I should not see this message on my user page.

ptmkenny’s picture

Title: send mail user message » don't show "send this user a private message" link on user's own page
Category: task » feature
Status: Active » Needs review
ptmkenny’s picture

Version: 7.x-1.3 » 7.x-1.x-dev
ptmkenny’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
StatusFileSize
new2.68 KB

Here's a patch with cavax's code. I added tests so that we can confirm the functionality works as intended over the long term.

Status: Needs review » Needs work
ptmkenny’s picture

Status: Needs work » Needs review
StatusFileSize
new2.68 KB

Attempt to fix test.

Status: Needs review » Needs work
ptmkenny’s picture

Status: Needs work » Needs review
StatusFileSize
new2.68 KB

Ah, the test was failing because there are no periods in the link. D'oh!

ptmkenny’s picture

And here's a "tests only" patch.

Status: Needs review » Needs work
ptmkenny’s picture

$user1 needs "view user profiles" permission.

Status: Needs review » Needs work
ptmkenny’s picture

"access user profiles" not "view user profiles"-- didn't realize the UI and the code were different.

This patch includes cavax's code and two tests by me, one to confirm that a user with appropriate permissions does not see a "send user a privatemsg" link on his/her own profile page (the modified behavior), and another test to confirm that the user does see a link on other users' profile pages (the previous behavior).

ptmkenny’s picture

Assigned: Unassigned » berdir
Status: Needs work » Needs review
berdir’s picture

Assigned: Unassigned » berdir

7.x-2.x has a setting for this, it's not needed there.

ptmkenny’s picture

Assigned: berdir » Unassigned
Status: Needs review » Closed (works as designed)

Oops, didn't realize that. Closing.