Created
December 1, 2023 10:36
-
-
Save adczk/30736ec67478ee287d3a7ab11bd870eb to your computer and use it in GitHub Desktop.
Revisions
-
adczk created this gist
Dec 1, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ <?php /** * Plugin Name: Block WordPress user account registration by e-mail domain * Plugin URI: https://gist.github.com/adczk * Description: Block WordPress user account registration by e-mail domain * Author: adczk * * Author URI: https://gist.github.com/adczk * License: GPLv2 or later * * Use as MU plugin; config in code comments * */ function wpmu_stop_registration_by_domain( $errors, $sanitized_user_login, $user_email ) { // below you list email domains to be blocked // comma-separated $blocked_domains = array( 'emaildomain.com', 'otherdomain.net', ); // custom error message $error_msg = "You're not allowed to register!"; foreach ( $blocked_domains as $key=>$value ) { if ( strpos( $user_email, $value ) !== false ) { $errors->add( 'banned_domain_error', $error_msg ); } } return $errors; } add_filter( 'registration_errors', 'wpmu_stop_registration_by_domain', 10, 3 );