function privatemsg_recipient_access

7-1 privatemsg.module privatemsg_recipient_access($type_name, $permission, $recipient = NULL)
7-2 privatemsg.module privatemsg_recipient_access($type_name, $permission, $recipient = NULL)
6-2 privatemsg.module privatemsg_recipient_access($type_name, $permission, $recipient = NULL)

This function is used to test if the current user has write/view access for a specific recipient type.


$type_name: The name of the recipient type.

$permission: Which permission should be checked: 'write' or 'view'.

$recipient: Optionally pass in a recipient for which the permission should be checked. This only has effect if a the recipient type defines a callback function and is simply passed through in that case.

Return value

TRUE if the user has that permission (or not permission is defined) and FALSE if not.

Related topics

5 calls to privatemsg_recipient_access()
privatemsg_autocomplete in ./
Return autocomplete results for usernames.
privatemsg_new in ./
Form builder function; Write a new private message.
_privatemsg_get_allowed_recipients in ./
Check if the current user is allowed to write these recipients.
_privatemsg_load_thread_participants in ./privatemsg.module
Load all participants of a thread.
_privatemsg_parse_userstring in ./privatemsg.module
Extract the valid usernames of a string and loads them.


./privatemsg.module, line 2703
Allows users to send private messages to other users.


function privatemsg_recipient_access($type_name, $permission, $recipient = NULL) {
  if (($type = privatemsg_recipient_get_type($type_name))) {
    // First check if a callback function is defined.
    if (!empty($type[$permission . ' callback']) && is_callable($type[$permission . ' callback'])) {
      $callback = $type[$permission . ' callback'];
      return $callback($recipient);

    if (isset($type[$permission . ' access'])) {
      if (is_bool($type[$permission . ' access'])) {
        return $type[$permission . ' access'];
      return user_access($type[$permission . ' access']);
  // If no access permission is defined, access is allowed.
  return TRUE;