Skip to content

Strip HTML tags from multisite user signup validation errors - #596

Merged
swissspidy merged 5 commits into
mainfrom
copilot/fix-error-message-creating-user
Mar 16, 2026
Merged

swissspidy merged 5 commits into
mainfrom
copilot/fix-error-message-creating-user

Conversation

Copilot AI commented Mar 15, 2026 •

Copy link
Copy Markdown
Contributor

wpmu_validate_user_signup() returns error messages with embedded HTML (e.g. <strong>Error:</strong> This email address is already registered. <a href="...">Log in</a>), which WP-CLI displayed verbatim — leaking markup into the terminal output.

Changes

  • User_Command::create() — apply wp_strip_all_tags() to each message from the WP_Error before passing to WP_CLI::error()
  • User_Command::import_csv() — same treatment before passing to WP_CLI::warning()
  • features/user.feature — new multisite scenario asserting the duplicate-email error is plain text and contains no < characters

Before:

Error: <strong>Error:</strong> This email address is already registered. <a href="http://example.com/wp-login.php">Log in</a> with this address or choose another one.

After:

Error: This email address is already registered.
Original prompt

This section details on the original issue you should resolve

<issue_title>Improve message in error trying to create user with existing email in multisite</issue_title>
<issue_description>## Bug Report

Describe the current, buggy behavior

When I try to create user in multisite with existing email address:

wp user create admin1 admin1@gmail.com --role=administrator

Error: <strong>Error:</strong> This email address is already registered. <a href="http://bahu.local/wp-login.php">Log in</a> with this address or choose another one.

Describe what you would expect as the correct outcome

Error: This email address is already registered.

Let us know what environment you are running this on

OS:     Darwin 22.6.0 Darwin Kernel Version 22.6.0: Tue Nov  7 21:48:06 PST 2023; root:xnu-8796.141.3.702.9~2/RELEASE_X86_64 x86_64
Shell:  /bin/zsh
PHP binary:     /usr/local/Cellar/php@8.2/8.2.15/bin/php
PHP version:    8.2.15
php.ini used:   /usr/local/etc/php/8.2/php.ini
MySQL binary:   /usr/local/bin/mysql
MySQL version:  mysql  Ver 8.3.0 for macos13.6 on x86_64 (Homebrew)
SQL modes:
WP-CLI root dir:        phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:      phar://wp-cli.phar/vendor
WP_CLI phar path:       /Users/nilambarsharma/Sites/bahu
WP-CLI packages dir:    /Users/nilambarsharma/.wp-cli/packages/
WP-CLI cache dir:       /Users/nilambarsharma/.wp-cli/cache
WP-CLI global config:
WP-CLI project config:  /Users/nilambarsharma/Sites/bahu/wp-cli.local.yml
WP-CLI version: 2.10.0

</issue_description>

Comments on the Issue (you are @copilot in this section)

@danielbachhuber Seems like a reasonable enhancement 👍

📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

@github-actions github-actions Bot added bug command:network-meta Related to 'network meta' command command:network Related to 'network' command command:option Related to 'option' command command:option-update Related to 'option update' command labels Mar 15, 2026
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix error message for existing email in multisite user creation Mar 15, 2026
Copilot AI requested a review from swissspidy March 15, 2026 22:20
@codecov

codecov Bot commented Mar 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@swissspidy
swissspidy marked this pull request as ready for review March 16, 2026 09:58
@swissspidy
swissspidy requested a review from a team as a code owner March 16, 2026 09:58
Copilot AI review requested due to automatic review settings March 16, 2026 09:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves WP-CLI multisite user creation/import UX by sanitizing HTML markup returned by wpmu_validate_user_signup() so terminal output stays plain text.

Changes:

  • Strip HTML tags from multisite signup validation error messages in wp user create.
  • Strip HTML tags from multisite signup validation warnings in wp user import-csv.
  • Add Behat coverage asserting duplicate-email errors contain no < characters (with version-specific expectations).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/User_Command.php Sanitizes WP_Error messages from multisite signup validation before emitting errors/warnings.
features/user.feature Adds multisite scenarios ensuring duplicate-email validation output is plain text (no markup).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread src/User_Command.php Resolved
Comment thread src/User_Command.php Resolved
Comment thread features/user.feature Resolved
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@swissspidy swissspidy added this to the 2.9.0 milestone Mar 16, 2026
@swissspidy
swissspidy merged commit 2b7531a into main Mar 16, 2026
69 checks passed
@swissspidy
swissspidy deleted the copilot/fix-error-message-creating-user branch March 16, 2026 11:46
swissspidy added a commit that referenced this pull request Nov 24, 2026
* Initial plan

* Fix: strip HTML tags from multisite user signup validation errors

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

* Fix test

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: Pascal Birchler <pascalb@google.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug command:network Related to 'network' command command:network-meta Related to 'network meta' command command:option Related to 'option' command command:option-update Related to 'option update' command

3 participants