Programatically create 'Send this user a a private message link' for user pages
Hope this will help you,

In Drupal 7, you can use privatemsg_get_link.


privatemsg_get_link - Returns a link to send message form for a specific users.

  if ($enabled_private_messages) {//check user private message settings
    if ($account = menu_get_object('user')) {// Get user object. You can also use user_load to get user object.
      if (is_object($account) &amp;&amp; privatemsg_user_access('write privatemsg')) {
        if ($url = privatemsg_get_link(array($account))) {
          return l(t('contact user'), $url, array('query' => drupal_get_destination()));
        }
      }
    }
  }