Skip to content

Commit c8a6c41

Browse files
authored
Merge pull request #191 from OpenSourceOrg/add/events-manager-honeypot-dev
Add filter to block honey pot field entries - dev
2 parents c1075fb + 0b6b2d6 commit c8a6c41

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
@@ -608,3 +608,25 @@ function osi_ssp_register_post_type_args( array $args ): array {
608608
return $args;
609609
}
610610
add_filter( 'ssp_register_post_type_args', 'osi_ssp_register_post_type_args', 10, 1 );
611+
612+
613+
/**
614+
* Block booking if honeypot phone field is filled.
615+
* Phone field is hidden using CSS.
616+
* Field must have the slug 'phone_hp', and must be a text input.
617+
*
618+
* @param boolean $result The result.
619+
* @param EM_Booking $em_booking The booking object.
620+
*
621+
* @return boolean The result.
622+
*/
623+
function osi_block_booking_if_phone_filled( $result, $em_booking ) {
624+
if ( ! empty( $em_booking->event ) ) {
625+
if ( isset( $_POST['phone_hp'] ) && trim( $_POST['phone_hp'] ) !== '' ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
626+
$em_booking->add_error( 'There was a problem with your booking. Please do not include a phone number.' );
627+
return false;
628+
}
629+
}
630+
return $result;
631+
}
632+
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)