Skip to content

Commit

Permalink
reset the blacklist to default on each field so it doesn't carry over…
Browse files Browse the repository at this point in the history
… from previous fields
  • Loading branch information
matt-h committed Sep 29, 2023
1 parent ae24226 commit 74d2130
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions includes/class-gfemailblacklist.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,11 @@ public function gf_emailblacklist_gform_editor_js() {
public function gf_emailblacklist_validation( $validation_result ) {

// Collect global settings.
$blacklist = get_option( 'gravityformsaddon_' . $this->_slug . '_settings' );
if ( is_array( $blacklist ) && ! empty( $blacklist['default_emailblacklist'] ) ) {
$blacklist = $blacklist['default_emailblacklist'];
$default_blacklist = get_option( 'gravityformsaddon_' . $this->_slug . '_settings' );
if ( is_array( $default_blacklist ) && ! empty( $default_blacklist['default_emailblacklist'] ) ) {
$default_blacklist = $default_blacklist['default_emailblacklist'];
} else {
$blacklist = '';
$default_blacklist = '';
}

// Collect form results.
Expand All @@ -231,6 +231,7 @@ public function gf_emailblacklist_validation( $validation_result ) {
}

// Collect banned domains from backend and clean up.
$blacklist = $default_blacklist;
if ( ! empty( $field['email_blacklist'] ) ) { // collect per form settings.
$blacklist = $field['email_blacklist'];
}
Expand All @@ -256,7 +257,9 @@ public function gf_emailblacklist_validation( $validation_result ) {
}

// Create array of banned domains.
$blacklist = explode( ',', $blacklist );
if ( ! is_array( $blacklist ) ) {
$blacklist = explode( ',', $blacklist );
}
$blacklist = str_replace( '*', '', $blacklist );
$blacklist = array_map( array( $this, 'gf_emailblacklist_clean' ), $blacklist );
$blacklist = array_filter( $blacklist );
Expand Down

0 comments on commit 74d2130

Please sign in to comment.