um_validation_safe_username_regex not allowing me to restrict additional chars?

I’m trying to use the um_validation_safe_username_regex filter (see below) to limit registration usernames only to alphanumeric characters. I’m enacting it as a Snippet and activating it. But Ultimate Member is allowing users to continue registering with the dashes, spaces, underscores, etc.

function um_custom_validation_safe_username( $regex_safe ) {
$regex_safe="/^[A-Za-z0-9]+$/";
return $regex_safe;
}
add_filter( 'um_validation_safe_username_regex', 'um_custom_validation_safe_username', 10, 1 );

Does this filter only add additional characters to allow, or can it be used to further restrict? I don’t understand why it’s not working.

  • This topic was modified 22 minutes ago by rando390.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer