__( 'IP Banned', 'advanced-form-integration' ), ); } /** * Get form fields. * * @param string $form_provider Provider name. * @param string $form_id Form ID. * * @return array|void */ function adfoin_solidsecurity_get_form_fields( $form_provider, $form_id ) { if ( 'solidsecurity' !== $form_provider || 'ipBanned' !== $form_id ) { return; } return array( 'ip_address' => __( 'Banned IP Address', 'advanced-form-integration' ), 'lockout_module' => __( 'Lockout Module (what triggered the ban)', 'advanced-form-integration' ), 'username' => __( 'Username (only when the ban came from a username lockout)', 'advanced-form-integration' ), 'ban_time' => __( 'Ban Time', 'advanced-form-integration' ), ); } /** * Handle a new permanent IP ban. * * @param string $ip The banned IP address. * @param object|null $context Lockout\Context instance, or null. */ function adfoin_solidsecurity_handle_banned_ip( $ip, $context ) { $integration = new Advanced_Form_Integration_Integration(); $records = $integration->get_by_trigger( 'solidsecurity', 'ipBanned' ); if ( empty( $records ) ) { return; } $lockout_module = ( $context && method_exists( $context, 'get_lockout_module' ) ) ? $context->get_lockout_module() : ''; // Only Username_Context exposes get_username(); Host_Context and other // module contexts don't, so this is best-effort and often blank. $username = ( $context && method_exists( $context, 'get_username' ) ) ? $context->get_username() : ''; $posted_data = array( 'ip_address' => $ip, 'lockout_module' => $lockout_module, 'username' => $username, 'ban_time' => current_time( 'mysql' ), ); adfoin_dispatch_integrations( $records, $posted_data ); }