You are here

regcode.api.php in Registration codes 6.2

Example hook functions for hooks provided by the core regcode module

File

regcode.api.php
View source
<?php

/** 
 * @file
 * Example hook functions for hooks provided by the core regcode module
 */

/**
 * Called when a registration code is used
 */
function hook_regcode_used(&$edit, &$account, &$code) {
  if (is_object($code)) {
    drupal_set_message(t('Thanks %name, the code %code was used.', array(
      '%name' => $account->name,
      '%code' => $edit['regcode_code'],
    )));
  }
}

/**
 * Called when validating registration code use
 */
function hook_regcode_validate($edit, $account) {
  if (empty($edit['loves_bacon'])) {
    form_set_error('regcode_code', t('This just isn\'t working out between us.'));
  }
}

/**
 * Called when a registration code is loaded
 */
function hook_regcode_load(&$code) {
  $code->group = 'foo';
}

/**
 * Called to gather field information
 */
function hook_regcode_fields() {
  return array(
    'group' => array(
      'description' => t('The group this code should be assigned to.'),
      'title' => t('Group'),
    ),
  );
}

Functions

Namesort descending Description
hook_regcode_fields Called to gather field information
hook_regcode_load Called when a registration code is loaded
hook_regcode_used Called when a registration code is used
hook_regcode_validate Called when validating registration code use