PluginProbe
Patchstack – WordPress & Plugins Security / 2.1.23
Patchstack – WordPress & Plugins Security v2.1.23
2.3.7 trunk 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.16 2.1.17 2.1.18 2.1.19 2.1.2 2.1.20 2.1.21 2.1.22 2.1.23 2.1.24 2.1.25 2.1.3 2.1.4 2.1.5 2.1.6 All 49 releases
patchstack / includes / events / users.php

users.php in Patchstack – WordPress & Plugins Security 2.1.23, at includes/events/users.php

136 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // Do not allow the file to be called directly.
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit;
6 }
7
8 /**
9 * This class is used to log any user related action.
10 */
11 class P_Event_Users extends P_Event_Log {
12
13 /**
14 * Hook into the actions so we can log it.
15 *
16 * @return void
17 */
18 public function __construct() {
19 add_action( 'wp_login', array( &$this, 'login' ), 10, 2 );
20 add_action( 'delete_user', array( &$this, 'deleteUser' ) );
21 add_action( 'user_register', array( &$this, 'register' ) );
22 add_action( 'profile_update', array( &$this, 'profileUpdate' ) );
23 add_action( 'validate_password_reset', array( &$this, 'resetPassword' ), 10, 2 );
24 add_filter( 'wp_login_failed', array( &$this, 'wrongPassword' ) );
25 }
26
27 /**
28 * When a user is logging in.
29 *
30 * @param string $user_login
31 * @param object $user
32 * @return void
33 */
34 public function login( $user_login, $user ) {
35 $this->insert(
36 array(
37 'action' => 'logged in',
38 'object' => 'user',
39 'object_id' => $user->ID,
40 'object_name' => esc_html( $user->user_nicename ),
41 )
42 );
43 }
44
45 /**
46 * When a new account has been created.
47 *
48 * @param integer $user_id
49 * @return void
50 */
51 public function register( $user_id ) {
52 $user = get_user_by( 'id', $user_id );
53 $this->insert(
54 array(
55 'action' => 'registered',
56 'object' => 'user',
57 'object_id' => $user->ID,
58 'object_name' => esc_html( $user->user_nicename ),
59 )
60 );
61 }
62
63 /**
64 * When a user is deleted.
65 *
66 * @param integer $user_id
67 * @return void
68 */
69 public function deleteUser( $user_id ) {
70 $user = get_user_by( 'id', $user_id );
71 $this->insert(
72 array(
73 'action' => 'deleted',
74 'object' => 'user',
75 'object_id' => $user->ID,
76 'object_name' => esc_html( $user->user_nicename ),
77 )
78 );
79 }
80
81 /**
82 * When a profile is updated.
83 *
84 * @param integer $user_id
85 * @return void
86 */
87 public function profileUpdate( $user_id ) {
88 $user = get_user_by( 'id', $user_id );
89 $this->insert(
90 array(
91 'action' => 'updated',
92 'object' => 'user',
93 'object_id' => $user->ID,
94 'object_name' => esc_html( $user->user_nicename ),
95 )
96 );
97 }
98
99 /**
100 * When a failed login attempt was made due to wrong password.
101 *
102 * @param string $username
103 * @return void
104 */
105 public function wrongPassword( $username ) {
106 $this->insert(
107 array(
108 'action' => 'failed login',
109 'object' => 'user',
110 'object_id' => 0,
111 'object_name' => esc_html( $username ),
112 )
113 );
114 }
115
116 /**
117 * When a password is being reset through the reset password procedure.
118 *
119 * @param object $errors
120 * @param object $user
121 * @return void
122 */
123 public function resetPassword( $errors, $user ) {
124 if ( is_a( $user, 'WP_User' ) ) {
125 $this->insert(
126 array(
127 'action' => 'password reset',
128 'object' => 'user',
129 'object_id' => 0,
130 'object_name' => esc_html( $user->user_login ),
131 )
132 );
133 }
134 }
135 }
136