Restrict sign-up to only specific domains

Hi,

You can simplify it a little:

add_filter(
	'hivepress/v1/forms/user_register/errors',
	function ( $errors, $form ) {
		$email = $form->get_value( 'email' );
		if ( strpos( $email, '.edu' ) === false ) {
			$errors [] = 'Only .edu email addresses are allowed.';
		}
		return $errors;
	},
	1000,
	2
);

Hope this helps

1 Like