| @@ -29,44 +29,25 @@ | ||
| 29 | 29 | */ |
| 30 | 30 | public function get_hooks(): array { |
| 31 | 31 | return array( |
| 32 | 32 | 'password_reset' => array( |
| 33 | - 'args' => array( 'user', 'new_pass' ), | |
| 33 | + 'args' => array( 'user' ), | |
| 34 | 34 | 'event_type' => Audit_Log::EVENT_TYPE_USER, |
| 35 | 35 | 'context' => self::CONTEXT_PASSWORD, |
| 36 | 36 | 'action_type' => self::ACTION_PASSWORD_CHANGED, |
| 37 | 37 | 'callback' => array( $this, 'password_reset' ), |
| 38 | 38 | ), |
| 39 | - 'profile_update' => array( | |
| 40 | - 'args' => array( 'user_id', 'old_user_data', 'userdata' ), | |
| 41 | - 'event_type' => Audit_Log::EVENT_TYPE_USER, | |
| 42 | - 'context' => self::CONTEXT_PASSWORD, | |
| 43 | - 'action_type' => self::ACTION_PASSWORD_CHANGED, | |
| 44 | - 'callback' => array( $this, 'profile_update' ), | |
| 45 | - ), | |
| 46 | 39 | ); |
| 47 | 40 | } |
| 48 | 41 | |
| 49 | 42 | /** |
| 50 | - * Callback for logging password changes via profile update. | |
| 43 | + * Logs a user profile update event. | |
| 51 | 44 | * |
| 52 | - * @param string $hook_name The name of the hook. | |
| 53 | - * @param array $params The parameters passed to the hook. | |
| 45 | + * @param int $user_id The ID of the user whose profile is being updated. | |
| 54 | 46 | * |
| 55 | - * @return bool|array | |
| 47 | + * @return bool|array False if the user is not found, otherwise an array containing the log message. | |
| 56 | 48 | */ |
| 57 | - public function profile_update( string $hook_name, array $params ): bool|array { | |
| 58 | - if ( User_Audit::is_create_user_action() ) { | |
| 59 | - return false; | |
| 60 | - } | |
| 61 | - | |
| 62 | - $user_id = $params['user_id']; | |
| 63 | - $post = defender_get_data_from_request( null, 'p' ); | |
| 64 | - // Password is not changed. | |
| 65 | - if ( ! isset( $post['pass1'] ) || '' === $post['pass1'] ) { | |
| 66 | - return false; | |
| 67 | - } | |
| 68 | - | |
| 49 | + public function profile_update( int $user_id ): bool|array { | |
| 69 | 50 | $user = get_user_by( 'id', $user_id ); |
| 70 | 51 | if ( ! $user ) { |
| 71 | 52 | return false; |
| 72 | 53 | } |
| @@ -114,15 +95,13 @@ | ||
| 114 | 95 | |
| 115 | 96 | /** |
| 116 | 97 | * Callback for logging password reset events( via reset link ) |
| 117 | 98 | * |
| 118 | - * @param string $hook_name The name of the hook. | |
| 119 | - * @param array $params The parameters passed to the hook. | |
| 99 | + * @param WP_User $user The user. | |
| 120 | 100 | * |
| 121 | 101 | * @return bool|array |
| 122 | 102 | */ |
| 123 | - public function password_reset( string $hook_name, array $params ): bool|array { | |
| 124 | - $user = $params['user']; | |
| 103 | + public function password_reset( $user ): bool|array { | |
| 125 | 104 | if ( ! $user instanceof WP_User ) { |
| 126 | 105 | return false; |
| 127 | 106 | } |
| 128 | 107 | |