How to prevent logging of unwanted actions
-
Currently I have days with about 8000 malicious login attemps. Thus I needed to prevent logging of the ‘Failed Login’ action. In 18 days nearly 24000 failed logins have been registered on the site.
As there is currently no admin interface available to configure the actions to be logged, I’ve set up some code which can be added to functions.php and suppresses the logging of a specific action.
I’ve added the code to remove the ‘Failed Login’ action as example.
add_action( 'init', 'stream_remove_action', 20); function stream_remove_action() { // WP hook, can be found at beginning of the php class file $hook = 'wp_login_failed'; // php class name of the connector $function_to_remove = 'WP_Stream_Connector_Users::callback'; remove_action( $hook, $function_to_remove, null); }
For other actions you need to replace the php class name of the related connector in $function_to_remove. For media use WP_Stream_Connector_Media::callback instead of WP_Stream_Connector_Users::callback. The .php files of the connector classes can be found in folder connectors.
The array $actions at the beginning of each connector class holds the WP hooks which are monitored. Take the hook you want to suppress and assign it to $hook (e.g. ‘edit_attachment’ from the media connector instead of ‘wp_login_failed’).
- The topic ‘How to prevent logging of unwanted actions’ is closed to new replies.