Register Message¶
-
do_action
(string $action, string $slug, array $args) → void Parameters: - $action (string) – Must be
wp_fail2ban_register_message
. - $slug (string) – The plugin slug used in Register Plugin.
- $args['slug'] (string) – The message slug.
- $args['fail'] (string) – Recommended action.
- $args['priority'] (int) –
syslog priority to use. Only the following priorities are supported:
- LOG_CRIT
- LOG_ERR
- LOG_WARNING
- LOG_NOTICE
- LOG_INFO
- LOG_DEBUG
- $args['event_class'] (string) –
Class of Event. This is one of:
- Auth
- Authentication-related Events.
- Block
- Blocking Events.
- Comment
- Comment-related Events.
- XMLRPC
- XML-RPC-related Events.
- Password
- Password-related Events.
- REST
- REST API-related Events.
- Spam
- Spam-related Events.
- $args['event_id'] (int) – Event ID - 16 bits you may do with as you please.
- $args['message'] (string) – Message with substitutions. Note that ” from <IP>” is appended.
- $args['vars'] (string[]) –
An array of substitutions mapped to regular expressions.
When logging a message the substitutions are checked and substituted if present. The regex will be used to generate a matching rule for fail2ban.
Throws: - InvalidArgumentException – Missing entry or invalid type. The
message
will give details. - UnexpectedValueException – Invalid value. The
message
will say which.
- $action (string) – Must be
Example¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | $args = [ 'slug' => 'my-plugin-msg-slug-1', 'fail' => 'hard', 'priority' => LOG_NOTICE, 'event_class' => 'Password', 'event_id' => 0x001F, 'message' => 'Message with ___VAR1___ and ___VAR2___', 'vars' => [ 'VAR1' => '\d+', 'VAR2' => '*.' ] ]; try { do_action('wp_fail2ban_register_message', 'my-plugin-slug', $args); } catch(\InvalidArgumentException $e) { // Missing entry or invalid type } catch(\UnexpectedValueException $e) { // Invalid value } |