PHPackages                             piwind/flarum-ext-username-blacklist - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. piwind/flarum-ext-username-blacklist

ActiveFlarum-extension[Validation &amp; Sanitization](/categories/validation)

piwind/flarum-ext-username-blacklist
====================================

Blacklist or whitelist specific username/nickname

v1.1.0(11mo ago)0108↓100%MITPHP

Since May 21Pushed 11mo agoCompare

[ Source](https://github.com/piwind/flarum-ext-username-blacklist)[ Packagist](https://packagist.org/packages/piwind/flarum-ext-username-blacklist)[ RSS](/packages/piwind-flarum-ext-username-blacklist/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

Username Blacklist
==================

[](#username-blacklist)

[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667) [![Latest Stable Version](https://camo.githubusercontent.com/078c1ab478600be377b4ad3362c02a206efa2a365099010eaced1e3d866488c9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f706977696e642f666c6172756d2d6578742d757365726e616d652d626c61636b6c6973742e737667)](https://packagist.org/packages/piwind/flarum-ext-username-blacklist) [![Total Downloads](https://camo.githubusercontent.com/a737bf3962103a59c9d5ab3d25c25acdf06303b861c6a58065bb839e92e2c2d6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f706977696e642f666c6172756d2d6578742d757365726e616d652d626c61636b6c6973742e737667)](https://packagist.org/packages/piwind/flarum-ext-username-blacklist)

This extension allows blacklisting or whitelisting username/nickname.

In default mode, a case-insensitive check is done with the provided username against the list.

In regular expression mode, the full username is checked against the regular expression (using PHP `preg_match` function). The regular expression must include delimiters and can include modifiers.

If no blacklist is defined, everything not whitelisted will be rejected. If a blacklist is defined, every whitelisted value as well as values not matched by the blacklist will be accepted.

The validation error message can be customized in the settings.

中文解释：

- 未定义黑名单的时候，仅白名单生效，只允许白名单中的值
- 定义黑名单后，黑名单中的拒绝，白名单中的无论黑名单中是否有都允许，两者都不在的也允许
- 建议正则表达式：开（不开的话，只有完全匹配的才排除掉）
- 示例黑名单：（以admin开头的，无论大小写的）

    ```
    /^admin/i

    ```

About This Fork
---------------

[](#about-this-fork)

This repository is a fork of [clarkwinkelmann/flarum-ext-username-blacklist](https://github.com/clarkwinkelmann/flarum-ext-username-blacklist), add support to blacklist nicknames if available.

Installation &amp; Updating
---------------------------

[](#installation--updating)

Install with composer:

```
composer require piwind/flarum-ext-username-blacklist
```

Updating:

```
composer update piwind/flarum-ext-username-blacklist
```

Feature
-------

[](#feature)

- PHP的 preg\_match() 函数，默认按Byte处理字符串，1个中文字符在UTF-8编码下通常占3个字节，因此如下的正则表达式有差异：

    ```
    string = 你好
    /^.{1,5}$/		不匹配
    /^.{1,5}$/u		匹配

    ```
- flarum默认行为：

    - 用户名至少3个字符
    - 更改昵称填写为空的话，会去掉昵称采纳跟username一样的名称
    - 用户名只能由字母、数字及连字符 (-) 组成 The username may only contain letters, numbers, and dashes. 翻译键为：core.api.invalid\_username\_message

        但实际上是只可以用 字母、数字、连字符、下划线
- 参考的实践方案加效果：（再加上flarum的默认行为）

    ```
    黑名单：
    /^admin/i
    /^.{1,5}$/
    /^[^\p{L}\p{N}]/u
    /[^\p{L}\p{N}]$/u

    ```

    username（限制比昵称多）：

    至少 6个英文字符或 2个中文字符，首位和末位不能是符号，不能含限制词；只可以用 字母、数字、连字符、下划线

    nickname：

    至少 6个英文字符或 2个中文字符，首位和末位不能是符号，不能含限制词

参考链接：

- [PHP: preg\_match - Manual](https://www.php.net/manual/en/function.preg-match.php)
- [javascript - Regex to allow any language characters in the form of full name and starting with letter - Stack Overflow](https://stackoverflow.com/questions/31534321/regex-to-allow-any-language-characters-in-the-form-of-full-name-and-starting-wit)

TODO
----

[](#todo)

- 【BUG】开启该插件会让Nicknames插件中设置的最小昵称长度失效

    具体行为：用户注册的时候，填写的昵称只需要满足至少 3 个字符就可以，在不满 3 个字符的时候，会报错 `validation.min.string`，须至少 6 个字符，但实际可以不满足这一条，只需满 3 个字符。

    但是在用户页的"更改昵称"按钮中，最小昵称长度设置又可以起效果。

    临时解决方案：

    ```
    黑名单中添加如下以匹配1~5位字符数的字符串：
    /^.{1,5}$/

    ```

    如上设置，就是至少 6 个英文字符，或者 2 个中文字符
- 【功能缺陷】username和nickname的黑白名单限制，没有分离开来，无法单独限制其一的规则。
- 【BUG】当用户设置昵称为全空格字符串的时候，会无视这个插件的规则，并设置成功

    在 src/WhitelistRule.php 中添加 error\_log，实测没有数值传入到该插件

Links
-----

[](#links)

- [GitHub](https://github.com/piwind/flarum-ext-username-blacklist)
- [Packagist](https://packagist.org/packages/piwind/flarum-ext-username-blacklist)

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance51

Moderate activity, may be stable

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 Bus Factor1

Top contributor holds 87.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

357d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3a0576f6449488040ef35236381afdb1fe3669a74b4b7a5cd66ea67c74ebdcd7?d=identicon)[piwind](/maintainers/piwind)

---

Top Contributors

[![piwind](https://avatars.githubusercontent.com/u/45837397?v=4)](https://github.com/piwind "piwind (7 commits)")[![clarkwinkelmann](https://avatars.githubusercontent.com/u/5264300?v=4)](https://github.com/clarkwinkelmann "clarkwinkelmann (1 commits)")

---

Tags

validationblacklistflarumusernamewhitelist

### Embed Badge

![Health badge](/badges/piwind-flarum-ext-username-blacklist/health.svg)

```
[![Health](https://phpackages.com/badges/piwind-flarum-ext-username-blacklist/health.svg)](https://phpackages.com/packages/piwind-flarum-ext-username-blacklist)
```

###  Alternatives

[composer/semver

Version comparison library that offers utilities, version constraint parsing and validation.

3.3k489.6M672](/packages/composer-semver)[giggsey/libphonenumber-for-php

A library for parsing, formatting, storing and validating international phone numbers, a PHP Port of Google's libphonenumber.

5.0k148.7M416](/packages/giggsey-libphonenumber-for-php)[respect/validation

The most awesome validation engine ever created for PHP

5.9k37.4M383](/packages/respect-validation)[propaganistas/laravel-phone

Adds phone number functionality to Laravel based on Google's libphonenumber API.

3.0k35.7M107](/packages/propaganistas-laravel-phone)[opis/json-schema

Json Schema Validator for PHP

64236.9M186](/packages/opis-json-schema)[giggsey/libphonenumber-for-php-lite

A lite version of giggsey/libphonenumber-for-php, which is a PHP Port of Google's libphonenumber

8412.9M47](/packages/giggsey-libphonenumber-for-php-lite)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
