You are here

function hook_access_grant_insert in Access Control Kit 7

Responds to the creation of a new access grant.

This hook is invoked from AccessGrantEntityController::save() after the database query that will insert the grant into the access_grant table is scheduled for execution and field_attach_insert() is called.

Note that when this hook is invoked, the changes have not yet been written to the database because a database transaction is still in progress. The transaction is not finalized until the save operation is entirely completed and the save() method goes out of scope. You should not rely on data in the database at this time, as it has not been updated yet. You should also note that any write/update database queries executed from this hook are also not committed immediately. Check AccessGrantEntityController::save() and db_transaction() for more info.

Parameters

object $grant: The access grant that is being created.

File

./access.api.php, line 416
Hooks provided by the access control kit module.

Code

function hook_access_grant_insert($grant) {

  // Notify the user whenever an access grant is added for user 1.
  if ($grant->uid == 1) {
    drupal_set_message(t('An access grant has been created for the site administrator.'));
  }
}