-
Notifications
You must be signed in to change notification settings - Fork 0
/
custom_user.module
71 lines (66 loc) · 1.94 KB
/
custom_user.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
if(!defined('LOGO_MAIL')){
define('LOGO_MAIL', base_path().drupal_get_path('module', 'custom_user')."/images/logo-mail.png");
}
/**
* Implements hook_theme().
**/
function custom_user_theme($existing, $type, $theme, $path) {
return [
'user_prehome' => [
'variables' => ['intro' => '', 'loginForm' => [], 'registerForm' => []],
],
'page_prehome' => [
'variables' => ['intro' => '', 'content' => []],
],
'user_mail_tpl' => [
'variables' => ['logo' => '', 'title' => '', 'greeting' => '', 'introduction' => '', 'contenu' => [], 'conclusion' => ''],
],
];
}
/**
* Implements hook_form_alter().
**/
function custom_user_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
global $user;
switch ($form_id) {
// login form
case 'user_login_form':
break;
// register form
case 'user_register_form':
$admin_context = \Drupal::service('router.admin_context');
if (!$admin_context->isAdminRoute()) {
unset($form['account']['status']);
unset($form['account']['roles']);
unset($form['field_date_de_naissance']);
unset($form['field_mobile']);
unset($form['field_nom']);
unset($form['field_prenom']);
}
break;
default:
break;
}
}
/**
* Implements hook_mail().
*/
function custom_user_mail($key, &$message, $params) {
$options = array(
'langcode' => $message['langcode'],
);
switch ($key) {
case 'accuse_inscription_fidele':
$message['from'] = \Drupal::config('system.site')->get('mail');
$message['subject'] = t('Accusé de reception de votre demande d\'inscription');
$message['body'][] = $params['message'];
break;
}
}
function myprint($var=NULL,$die=TRUE){
print '<pre>';
print "---------START--------";
var_dump($var);
if($die){ die("die"); }else{ print '---------END---------'; }
}