• Resolved Dylan Nunns

    (@dylannunns)


    Hey there Edir,

    I am looking to send out Vulnerability Reports to multiple people through your plugin. I noticed that it is not able to handle that in its current state.

    Right now if you try and add multiple emails, the validation method using is_email() validates as false, as [email protected],[email protected] will validate as an incorrect email.

    I modified the validation method to support handling multiple email addresses. Is this something that could be addressed? Or is there a way I could create assist on the plugin and create a Pull Request for the change?

    Here are the changes I made:

    Modified in vulnerability-alerts.php

    
    /*
    * 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 added a line to the introduction explaining how to add multiple e-mails for notifications.

    
    /*
    * 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>';
    
    }
    
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Multiple Emails for Alerts (Code Within)’ is closed to new replies.