_contact_user_tab_access

Versions
6
_contact_user_tab_access($account)

Menu access callback for a user's personal contact form.

Parameters

$account A user account object.

Return value

TRUE if the current user has access to the requested user's contact form, or FALSE otherwise.

Code

modules/contact/contact.module, line 120

<?php
function _contact_user_tab_access($account) {
  global $user;

  // Anonymous users cannot use or have contact forms.
  if (!$user->uid || !$account->uid) {
    return FALSE;
  }

  // User administrators should always have access to personal contact forms.
  if (user_access('administer users')) {
    return TRUE;
  }

  // Users may not contact themselves.
  if ($user->uid == $account->uid) {
    return FALSE;
  }

  // If the requested user has disabled their contact form, or this preference
  // has not yet been saved, do not allow users to contact them.
  if (empty($account->contact)) {
    return FALSE;
  }

  return TRUE;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.