Skip to content

Commit cbbbe48

Browse files
committed
Add filter to block honey pot field entries
1 parent 10b5fed commit cbbbe48

File tree

6 files changed

+38
-2
lines changed

6 files changed

+38
-2
lines changed

themes/osi/assets/css/editor-style.css

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

themes/osi/assets/css/editor-style.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

themes/osi/assets/scss/_7_vendor.plugins.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,9 @@ form.wp-block-jetpack-contact-form {
110110
.single-event .entry-header .wp-block-cover {
111111
aspect-ratio: 16 / 9;
112112
min-height: auto;
113+
}
114+
115+
/* Hide Events Manager Honeypot phone field */
116+
p.input-group.input-text.em-input-text.input-field-phone_hp {
117+
display: none!important;
113118
}

themes/osi/functions.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,3 +521,25 @@ function osi_ssp_register_post_type_args( $args ) {
521521
return $args;
522522
}
523523
add_filter( 'ssp_register_post_type_args', 'osi_ssp_register_post_type_args', 10, 1 );
524+
525+
526+
/**
527+
* Block booking if honeypot phone field is filled.
528+
* Phone field is hidden using CSS.
529+
* Field must have the slug 'phone_hp', and must be a text input.
530+
*
531+
* @param boolean $result The result.
532+
* @param EM_Booking $EM_Booking The booking object.
533+
*
534+
* @return boolean The result.
535+
*/
536+
function osi_block_booking_if_phone_filled( $result, $em_booking ) {
537+
if ( ! empty( $em_booking->event ) ) {
538+
if ( isset( $_POST['phone_hp'] ) && trim( $_POST['phone_hp'] ) !== '' ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
539+
$em_booking->add_error( 'There was a problem with your booking. Please do not include a phone number.' );
540+
return false;
541+
}
542+
}
543+
return $result;
544+
}
545+
add_filter( 'em_booking_validate', 'osi_block_booking_if_phone_filled', 10, 2 );

themes/osi/style.css

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

themes/osi/style.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)