You are here

function hook_domain_validate_alter in Domain Access 8

Same name and namespace in other branches
  1. 6.2 API.php \hook_domain_validate_alter()
  2. 7.3 domain.api.php \hook_domain_validate_alter()
  3. 7.2 domain.api.php \hook_domain_validate_alter()

Alter the validation step of a domain record.

This hook allows modules to change or extend how domain validation happens. Most useful for international domains or other special cases where a site wants to restrict domain creation is some manner.

NOTE: This does not apply to Domain Alias records.

No return value. Modify $error_list by reference. Return an empty array or NULL to validate this domain.

Parameters

array &$error_list: The list of current validation errors. Modify this value by reference. If you return an empty array or NULL, the domain is considered valid.

string $hostname: The HTTP_HOST string value being validated, such as one.example.com. Note that this is checked for uniqueness separately. This value is not modifiable.

See also

domain_valid_domain()

1 function implements hook_domain_validate_alter()

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

domain_test_domain_validate_alter in domain/tests/modules/domain_test/domain_test.module
Implements hook_domain_validate_alter().
1 invocation of hook_domain_validate_alter()
DomainValidator::validate in domain/src/DomainValidator.php
Validates the hostname for a domain.

File

domain/domain.api.php, line 104
API documentation file for Domain module.

Code

function hook_domain_validate_alter(array &$error_list, $hostname) {

  // Only allow TLDs to be .org for our site.
  if (substr($hostname, -4) != '.org') {
    $error_list[] = t('Only .org domains may be registered.');
  }
}