dddd
Signed-off-by: Jeff <jeff@gotenzing.com>
Showing
2 changed files
with
44 additions
and
1 deletions
| ... | @@ -125,3 +125,46 @@ function um_logout_user_links_new( $args ) { | ... | @@ -125,3 +125,46 @@ function um_logout_user_links_new( $args ) { |
| 125 | 125 | ||
| 126 | <?php | 126 | <?php |
| 127 | } | 127 | } |
| 128 | |||
| 129 | |||
| 130 | function um_validate_email_domain( $args ) { | ||
| 131 | |||
| 132 | // Change allowed email domains here | ||
| 133 | $allowed_email_domains = apply_filters( 'um_allowed_email_domains', array( | ||
| 134 | 'gotenzing.com', | ||
| 135 | 'ekccu.com', | ||
| 136 | 'stellervista.com' | ||
| 137 | ) ); | ||
| 138 | |||
| 139 | // Change error message here | ||
| 140 | $message = __( 'You can not use this email domain for registration', 'ultimate-member' ); | ||
| 141 | |||
| 142 | if ( isset( $args['user_email'] ) && is_email( $args['user_email'] ) ) { | ||
| 143 | $email_domain = array_pop( explode( '@', trim( $args['user_email'] ) ) ); | ||
| 144 | if ( !in_array( $email_domain, $allowed_email_domains ) ) { | ||
| 145 | UM()->form()->add_error( 'user_email', $message ); | ||
| 146 | } | ||
| 147 | } | ||
| 148 | } | ||
| 149 | add_action( 'um_submit_form_errors_hook__registration', 'um_validate_email_domain', 20 ); | ||
| 150 | |||
| 151 | |||
| 152 | function is_valid_email_domain($login, $email, $errors ){ | ||
| 153 | $valid_email_domains = array("gotenzing.com","ekccu.com","stellervista.com");// allowed domains | ||
| 154 | $valid = false; // sets default validation to false | ||
| 155 | foreach( $valid_email_domains as $d ){ | ||
| 156 | $d_length = strlen( $d ); | ||
| 157 | $current_email_domain = strtolower( substr( $email, -($d_length), $d_length)); | ||
| 158 | if( $current_email_domain == strtolower($d) ){ | ||
| 159 | $valid = true; | ||
| 160 | break; | ||
| 161 | } | ||
| 162 | } | ||
| 163 | // Return error message for invalid domains | ||
| 164 | if( $valid === false ){ | ||
| 165 | |||
| 166 | $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.' )); | ||
| 167 | } | ||
| 168 | } | ||
| 169 | add_action('register_post', 'is_valid_email_domain',10,3 ); | ||
| 170 | |||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -5,7 +5,7 @@ | ... | @@ -5,7 +5,7 @@ |
| 5 | Author: the Understrap Contributors | 5 | Author: the Understrap Contributors |
| 6 | Author URI: https://github.com/understrap/understrap-child/graphs/contributors | 6 | Author URI: https://github.com/understrap/understrap-child/graphs/contributors |
| 7 | Template: understrap | 7 | Template: understrap |
| 8 | Version: 1.2.0019 | 8 | Version: 1.2.0020 |
| 9 | License: GNU General Public License v2 or later | 9 | License: GNU General Public License v2 or later |
| 10 | License URI: http://www.gnu.org/licenses/gpl-2.0.html | 10 | License URI: http://www.gnu.org/licenses/gpl-2.0.html |
| 11 | Text Domain: understrap-child | 11 | Text Domain: understrap-child | ... | ... |
-
Please register or sign in to post a comment