forked from ekino/ekino-wordpress-symfony
-
Notifications
You must be signed in to change notification settings - Fork 2
/
hook.php
57 lines (50 loc) · 1.67 KB
/
hook.php
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
<?php
/*
* This file is part of the Ekino Wordpress package.
*
* (c) 2011 Ekino
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Dispatch Wordpress user login hook on Symfony event dispatcher
*
* @param string $user_login Username of user logged in
* @param \WP_User $user Wordpress user object
*
* @see http://codex.wordpress.org/Plugin_API/Action_Reference/wp_login
*/
function ekino_wordpress_symfony_hook_wp_login($user_login, $user) {
$event = new \Ekino\WordpressBundle\Event\WordpressEvent(array(
'user_login' => $user_login,
'user' => $user
));
symfony_event_dispatch('ekino.wordpress.user_login', $event);
}
/**
* Dispatch Wordpress user auth cookie validation on Symfony event dispatcher
* only if trying to access the administration page
*
* @param array $cookie_elements Wordpress cookie data
* @param \WP_User $user Wordpress user object
*/
function ekino_wordpress_symfony_hook_wp_login_cookie($cookie_elements, $user) {
if (!is_admin()) {
return;
}
$event = new \Ekino\WordpressBundle\Event\WordpressEvent(array(
'cookie_elements' => $cookie_elements,
'user' => $user
));
symfony_event_dispatch('ekino.wordpress.user_login', $event);
}
/**
* Dispatch Wordpress user log out hook on Symfony event dispatcher
*
* @see http://codex.wordpress.org/Plugin_API/Action_Reference/wp_logout
*/
function ekino_wordpress_symfony_hook_wp_logout() {
$event = new \Ekino\WordpressBundle\Event\WordpressEvent();
symfony_event_dispatch('ekino.wordpress.user_logout', $event);
}