You are here

function hook_node_registration_access in Node registration 7

Implements hook_node_registration_access().

Override standard NR access for any operation.

Parameters

NodeRegistrationEntityClass $registration: The relevant $registration, which might be new (so no registration_id) in case of operation 'add'/'create'.

string $op: The operation this access overrides. One of: delete, view, cancel, edit/update, add/create. The last two have aliases you must check for.

stdClass $account: The relevant user object that tries to do this $op to this $registration. Never empty;

string $reason: The reason the standard NR access was FALSE. Relevant for all operations. If the reason is unknown, this will be '?', so it's only empty IF access was granted by standard NR logic. This argument is useful if your code has expensive logic to disallow a certain operation: if $reason is not empty AND you're the only module overriding this access, your expensive code doesn't have to run.

1 function implements hook_node_registration_access()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

nr_owners_node_registration_access in submodules/nr_owners/nr_owners.module
Implements hook_node_registration_access().
1 invocation of hook_node_registration_access()
node_registration_access in includes/node_registration.api.inc
All Registration access callbacks. Just like node.module has node_access.

File

./node_registration.api.php, line 24

Code

function hook_node_registration_access($registration, $op, $account, $reason) {
  $event_node = $registration->node;
  $settings = $event_node->registration;
  switch ($op) {
    case 'cancel':

      // Normally, a user can't cancel others' registrations.
      if ($reason && $registration->author_uid == $account->uid) {

        // But we did something with author_uid, so now it's okay.
        return TRUE;
      }
      break;
    case 'add':
    case 'create':

      // We don't like registrations on Wednesdays, even for admins.
      if (date('w', REQUEST_TIME) == 3) {
        return FALSE;
      }

      // Normally NR only allows 1 registration per user.
      if ($reason == 'registered') {

        // But this user can register guests.
        if (_some_magic_function($account)) {
          return TRUE;
        }
      }
      break;
  }
}