Skip to content

Remove HTML tags from error message when creating user in multisite #473

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions features/user.feature
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,12 @@ Feature: Manage WordPress users
Bob Jones
"""

When I try `wp user create bobjones1 bobjones@example.com`
Then STDERR should contain:
"""
Error: This email address is already registered.
"""

Scenario: Managing user roles
Given a WP install

Expand Down
7 changes: 6 additions & 1 deletion src/User_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,12 @@ public function create( $args, $assoc_args ) {
if ( is_multisite() ) {
$result = wpmu_validate_user_signup( $user->user_login, $user->user_email );
if ( is_wp_error( $result['errors'] ) && ! empty( $result['errors']->errors ) ) {
WP_CLI::error( $result['errors'] );
$message = $result['errors']->get_error_message();
if ( false !== stripos( $message, '</strong>' ) ) {
$exploded = explode( '</strong>', $message );
$message = trim( wp_strip_all_tags( $exploded[1] ) );
}
WP_CLI::error( $message );
}
$user_id = wpmu_create_user( $user->user_login, $user->user_pass, $user->user_email );
if ( ! $user_id ) {
Expand Down