Skip to content

Instantly share code, notes, and snippets.

@NateWr
Created August 25, 2017 08:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NateWr/5970f09425f3cbffe0494bd9c8a1ca94 to your computer and use it in GitHub Desktop.
Save NateWr/5970f09425f3cbffe0494bd9c8a1ca94 to your computer and use it in GitHub Desktop.
Prevent bookings from being made with @aol.com email addresses.
<?php
/**
* Plugin Name: Block AOL bookings for Restaurant Reservations
* Plugin URI: http://themeofthecrop.com
* Description: Prevent bookings from being made with @aol.com email addresses.
* Version: 1.0
* Author: Theme of the Crop
* Author URI: http://themeofthecrop.com
* License: GNU General Public License v2.0 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU
* General Public License as published by the Free Software Foundation; either version 2 of the License,
* or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU General Public License along with this program; if not, write
* to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
if ( ! defined( 'ABSPATH' ) )
exit;
/**
* Check if a reservations's email address includes @aol.com
*/
add_action( 'rtb_validate_booking_submission', 'rtbbaol_block_aol_emails' );
function rtbbaol_block_aol_emails( $booking ) {
if ( !empty( $booking->email ) && strpos( $booking->email, '@aol.com' ) !== false ) {
$booking->validation_errors[] = array(
'field' => 'email',
'post_variable' => $_POST['rtb-email'],
'message' => __( 'Bookings from @aol.com are not accepted at this time. Please use a different email address.', 'restaurant-reservations' ),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment