4c19c8b0 by Jeff Balicki

dddd

Signed-off-by: Jeff <jeff@gotenzing.com>
1 parent 42afe874
......@@ -125,3 +125,46 @@ function um_logout_user_links_new( $args ) {
<?php
}
function um_validate_email_domain( $args ) {
// Change allowed email domains here
$allowed_email_domains = apply_filters( 'um_allowed_email_domains', array(
'gotenzing.com',
'ekccu.com',
'stellervista.com'
) );
// Change error message here
$message = __( 'You can not use this email domain for registration', 'ultimate-member' );
if ( isset( $args['user_email'] ) && is_email( $args['user_email'] ) ) {
$email_domain = array_pop( explode( '@', trim( $args['user_email'] ) ) );
if ( !in_array( $email_domain, $allowed_email_domains ) ) {
UM()->form()->add_error( 'user_email', $message );
}
}
}
add_action( 'um_submit_form_errors_hook__registration', 'um_validate_email_domain', 20 );
function is_valid_email_domain($login, $email, $errors ){
$valid_email_domains = array("gotenzing.com","ekccu.com","stellervista.com");// allowed domains
$valid = false; // sets default validation to false
foreach( $valid_email_domains as $d ){
$d_length = strlen( $d );
$current_email_domain = strtolower( substr( $email, -($d_length), $d_length));
if( $current_email_domain == strtolower($d) ){
$valid = true;
break;
}
}
// Return error message for invalid domains
if( $valid === false ){
$errors->add('domain_whitelist_error',__( '<strong>ERROR</strong>: Registration is only allowed from selected approved domains. If you think you are seeing this in error, please contact the system administrator.' ));
}
}
add_action('register_post', 'is_valid_email_domain',10,3 );
\ No newline at end of file
......
......@@ -5,7 +5,7 @@
Author: the Understrap Contributors
Author URI: https://github.com/understrap/understrap-child/graphs/contributors
Template: understrap
Version: 1.2.0019
Version: 1.2.0020
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: understrap-child
......