function invite_target_roles in Invite 7.2
Same name and namespace in other branches
- 6.2 invite.module \invite_target_roles()
- 7.4 invite.module \invite_target_roles()
Determine target roles based on the roles of an inviter.
Parameters
$invite: An invite object.
$accout: The user for whom the role is being determined.
Return value
Array of target roles for an invited user.
1 call to invite_target_roles()
- invite_user_presave in ./
invite.module - Implements hook_user_presave().
File
- ./
invite.module, line 759 - Allows your users to send and track invitations to join your site.
Code
function invite_target_roles($invite, $account) {
$targets = array();
$roles = array();
// Add roles of inviter.
if ($invite->inviter) {
$roles = array_intersect($invite->inviter->roles, user_roles(TRUE, 'send invitations'));
}
// Add a dummy entry to retrieve the default target role setting.
$roles['default'] = 'default';
// Map to configured target roles.
foreach ($roles as $rid => $role) {
$target = variable_get('invite_target_role_' . $rid, DRUPAL_AUTHENTICATED_RID);
if ($target != DRUPAL_AUTHENTICATED_RID) {
$targets[$target] = $target;
}
}
invite_invoke_all('invite_target_roles', $targets, $invite, $account);
return $targets;
}