Multiple Email Support for Alerts
-
Hey Edir,
I am looking to send reports to multiple e-mail addresses with your plugin. However in its current state, it does not support that feature to handle validating multiple e-mails.
I found that it will not support these multiple e-mails because of the function is_email() in your validate method.
I added the ability to manage this functionality in locally and have it working.
I’d love if this could make it in to a patch in the near future so I can start pushing out reports to multiple people.
The changes I made to support this are below.
/* * Validating fields */ static public function validate($input) { if ( ! empty( $input['email'] ) ) { // Remove any whitespace $input['email'] = preg_replace('/\s/', '', $input['email']); // Check for multiple emails, separated by the comma (,) $emails = explode( ',', $input['email'] ); // Loop through the emails and ensure they are all valid foreach ( $emails as $email ) { if ( ! is_email( $email ) ) { add_settings_error( self::$id . '_notification', 'invalid-email', __( 'You have entered an invalid e-mail address.', self::$id ) ); } } } return $input; }I also extended the Introduction to notify how to add multiple e-mails.
/* * Introduction */ static public function introduction() { echo '<p>' . __('Fill the options below if you want to be notified by mail about new vulnerabilities. To add multiple e-mail addresses, separate them via comma (,).', self::$id) . '</p>'; }
The topic ‘Multiple Email Support for Alerts’ is closed to new replies.