Bonjour à tous,
Je souhaite envoyer un mail à l’utilisateur concerné lorsque je modifie son rôle. Ce mail dépend du rôle choisi.
Exemple : l’admin change le rôle de monsieur X en rôle Y. Monsieur X reçoit un mail qui lui indique son nouveau rôle, à savoir Y. Il y aura des textes personnalisés selon le rôle choisi.
Pour cela, je me suis orienté vers les triggers. J’ai créé un module «role_changing» qui permet d’ajouter un nouveau trigger dans un nouvel onglet. Mais voilà, il n’y a pas d’action possible à associer alors que j’ai activé l’action «Envoi de mail».
Merci.
Voici mon code :
<?php
/<strong>
* Implementation of hook_hook_info()
* Declare a new trigger.
*/
function role_changing_hook_info() {
return array(
'role_changing' => array(
'role_changing' => array(
'update' => array(
'runs when' => t('When user role has been changed'),
),
),
),
);
}
/</
strong>
* Implementation of hook_user()
*/
function role_changing_user($op, &$edit, &$account, $category = NULL) {
switch ($op) {
case 'update':
if($account->uid == 24) // Au pif mais existe, juste pour tester
module_invoke_all('role_changing', 'update');
break;
}
}
/**
* Implementation of hook_role_changing()
*/
function role_changing_role_changing($op) {
$aids = _trigger_get_hook_aids('role_changing', $op);
$context = array(
'hook' => 'role_changing',
'op' => $op,
);
actions_do(array_keys($aids), $context);
}
?>- Vous devez vous identifier ou créer un compte pour écrire des commentaires
