You are here

function hook_user_external_invite_pre_grant_invite in User External Invite 7.2

Same name and namespace in other branches
  1. 7 user_external_invite.api.php \hook_user_external_invite_pre_grant_invite()
  2. 1.0.x user_external_invite.api.php \hook_user_external_invite_pre_grant_invite()

Perform actions or checks before an invite is granted.

In this hook, you can perform any checks you would want to prevent the role from being granted. The only reason to return anything is if you want the invite process to be halted. Any message you return will be displayed to the user along with any other messages from subscribers to this hook.

Parameters

object $account: The user account that will be granted a role.

int $grant_rid: The role id that the user account will be granted.

Return value

string The error message shown to the user for why no role was granted.

1 invocation of hook_user_external_invite_pre_grant_invite()
user_external_invite_grant_invite in ./user_external_invite.module
Grants an invite given a token and mail.

File

./user_external_invite.api.php, line 36
Contains hooks provided by the user_external_invite module.

Code

function hook_user_external_invite_pre_grant_invite($account, $grant_rid) {

  // If email is in a list of emails we don't want to grant roles to,
  // prevent granting.
  // This is a fictional function you would have to implement in your module.
  $blocked_emails = your_module_check_blocked_emails();
  if (in_array($account->mail, $blocked_emails)) {
    return t('The email associated with this account cannot be granted user roles.');
  }
}