Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter( 'jnews_register_default_role', 'jnews_registrarion_without_spaces', 10 );
- add_filter( 'registration_errors', 'wp_registrarion_without_spaces', 10, 3 );
- /**
- * Restrict username on JNews regisration.
- */
- function jnews_registrarion_without_spaces( $default_role ) {
- $user_login = sanitize_user( wp_unslash( $_POST['username'] ) );
- if ( ! preg_match( '/^[a-zA-Z0-9]+$/', $user_login ) ) {
- throw new \Exception( 'Username hanya boleh terdiri dari huruf dan angka tanpa spasi atau simbol' );
- }
- return $default_role;
- }
- /**
- * Restrict username on WordPress regisration.
- */
- function wp_registrarion_without_spaces( $errors, $sanitized_user_login, $user_email ) {
- if ( ! preg_match( '/^[a-zA-Z0-9]+$/', $sanitized_user_login ) ) {
- $errors->add( 'username_invalid', __( 'Username hanya boleh terdiri dari huruf dan angka tanpa spasi atau simbol.', 'textdomain' ) );
- }
- return $errors;
- }
Add Comment
Please, Sign In to add comment