Do you have an example of hook_menu() access callback? I have downloaded the examples project, but in the menu_example module all the access callback are set to true.. hard to understand how it works.

In my example, my meno entry should be visible on nodes, but only for roles that have the permissions to edit his own nodes.

I cant find an example a bit more verbose of an access callback.

Do anyone have one?
Drupal is itself an example of how to write code. 

The easier example is aggregator_menu(), which contains the following code.

  $items['admin/config/services/aggregator'] = array(
    'title' =&gt; 'Feed aggregator', 
    'description' =&gt; "Configure which content your site aggregates from other sites, how often it polls them, and how they're categorized.", 
    'page callback' =&gt; 'aggregator_admin_overview', 
    'access arguments' =&gt; array('administer news feeds'), 
    'weight' =&gt; 10, 
    'file' =&gt; 'aggregator.admin.inc',
  );
  $items['admin/config/services/aggregator/add/feed'] = array(
    'title' =&gt; 'Add feed', 
    'page callback' =&gt; 'drupal_get_form', 
    'page arguments' =&gt; array('aggregator_form_feed'), 
    'access arguments' =&gt; array('administer news feeds'), 
    'type' =&gt; MENU_LOCAL_ACTION, 
    'file' =&gt; 'aggregator.admin.inc',
  );


In this case, the access callback is the default (user_access()), and the access arguments are an array containing the string for the permission. The code cannot check more than a permission; if the permissions to check are two, or the conditions to check are not just permissions, then the access callback should be a different one, including a custom one.

node_menu() define some menus that use an access callback different from the default one. The function contains the following code.

  foreach (node_type_get_types() as $type) {
    $type_url_str = str_replace('_', '-', $type-&gt;type);
    $items['node/add/' . $type_url_str] = array(
      'title' =&gt; $type-&gt;name, 
      'title callback' =&gt; 'check_plain', 
      'page callback' =&gt; 'node_add', 
      'page arguments' =&gt; array($type-&gt;type), 
      'access callback' =&gt; 'node_access', 
      'access arguments' =&gt; array('create', $type-&gt;type), 
      'description' =&gt; $type-&gt;description, 
      'file' =&gt; 'node.pages.inc',
    );
  }


The function that is defined as access callback (node_access()) is the following one:

function node_access($op, $node, $account = NULL) {
  $rights = &amp;drupal_static(__FUNCTION__, array());

  if (!$node || !in_array($op, array('view', 'update', 'delete', 'create'), TRUE)) {
    // If there was no node to check against, or the $op was not one of the
    // supported ones, we return access denied.
    return FALSE;
  }
  // If no user object is supplied, the access check is for the current user.
  if (empty($account)) {
    $account = $GLOBALS['user'];
  }

  // $node may be either an object or a node type. Since node types cannot be
  // an integer, use either nid or type as the static cache id.

  $cid = is_object($node) ? $node-&gt;nid : $node;

  // If we've already checked access for this node, user and op, return from
  // cache.
  if (isset($rights[$account-&gt;uid][$cid][$op])) {
    return $rights[$account-&gt;uid][$cid][$op];
  }

  if (user_access('bypass node access', $account)) {
    $rights[$account-&gt;uid][$cid][$op] = TRUE;
    return TRUE;
  }
  if (!user_access('access content', $account)) {
    $rights[$account-&gt;uid][$cid][$op] = FALSE;
    return FALSE;
  }

  // We grant access to the node if both of the following conditions are met:
  // - No modules say to deny access.
  // - At least one module says to grant access.
  // If no module specified either allow or deny, we fall back to the
  // node_access table.
  $access = module_invoke_all('node_access', $node, $op, $account);
  if (in_array(NODE_ACCESS_DENY, $access, TRUE)) {
    $rights[$account-&gt;uid][$cid][$op] = FALSE;
    return FALSE;
  }
  elseif (in_array(NODE_ACCESS_ALLOW, $access, TRUE)) {
    $rights[$account-&gt;uid][$cid][$op] = TRUE;
    return TRUE;
  }

  // Check if authors can view their own unpublished nodes.
  if ($op == 'view' &amp;&amp; !$node-&gt;status &amp;&amp; user_access('view own unpublished content', $account) &amp;&amp; $account-&gt;uid == $node-&gt;uid &amp;&amp; $account-&gt;uid != 0) {
    $rights[$account-&gt;uid][$cid][$op] = TRUE;
    return TRUE;
  }

  // If the module did not override the access rights, use those set in the
  // node_access table.
  if ($op != 'create' &amp;&amp; $node-&gt;nid) {
    if (module_implements('node_grants')) {
      $query = db_select('node_access');
      $query-&gt;addExpression('1');
      $query-&gt;condition('grant_' . $op, 1, '&gt;=');
      $nids = db_or()-&gt;condition('nid', $node-&gt;nid);
      if ($node-&gt;status) {
        $nids-&gt;condition('nid', 0);
      }
      $query-&gt;condition($nids);
      $query-&gt;range(0, 1);

      $grants = db_or();
      foreach (node_access_grants($op, $account) as $realm =&gt; $gids) {
        foreach ($gids as $gid) {
          $grants-&gt;condition(db_and()
            -&gt;condition('gid', $gid)
            -&gt;condition('realm', $realm)
          );
        }
      }
      if (count($grants) &gt; 0) {
        $query-&gt;condition($grants);
      }
      $result =  (bool) $query
        -&gt;execute()
        -&gt;fetchField();
      $rights[$account-&gt;uid][$cid][$op] = $result;
      return $result;
    }
    elseif (is_object($node) &amp;&amp; $op == 'view' &amp;&amp; $node-&gt;status) {
      // If no modules implement hook_node_grants(), the default behavior is to
      // allow all users to view published nodes, so reflect that here.
      $rights[$account-&gt;uid][$cid][$op] = TRUE;
      return TRUE;
    }
  }

  return FALSE;
}


There are three points to notice:


The arguments declared with "access arguments" will be passed to the function in the same order; the function uses a third parameter because it is not used only access callback.
The function returns TRUE if the user has access to the menu, and FALSE if the user doesn't have access to the menu.
An access callback can also be used when a menu should be shown only in specific circumstances.