Skip to content

Commit

Permalink
Update logic to display error message on users screen
Browse files Browse the repository at this point in the history
  • Loading branch information
agrullon95 committed May 2, 2024
1 parent 6e2778e commit ea4c2cf
Showing 1 changed file with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -256,22 +256,27 @@ public function invite_user_to_wpcom() {
);

if ( 200 !== wp_remote_retrieve_response_code( $response ) ) {
$error_code = 'invalid-invite-api-error';
$error_message = is_wp_error( $response ) ? $response->get_error_message() : wp_remote_retrieve_response_message( $response );
$query_params = array(
$error_code = 'invalid-invite-api-error';
$query_params = array(
'jetpack-sso-invite-user' => 'failed',
'jetpack-sso-invite-error' => $error_code,
'jetpack-sso-invite-api-error-message' => $error_message,
'_wpnonce' => $nonce,
);

$tracking_event_data = array(
'success' => 'false',
'error_code' => $error_code,
);

$body = json_decode( $response['body'] );
if ( $body && $body->message ) {
$query_params['jetpack-sso-invite-api-error-message'] = $body->message;
$tracking_event_data['error_message'] = $body->message;
}

self::$tracking->record_user_event(
$event,
array(
'success' => 'false',
'error_code' => $error_code,
'error_message' => $error_message,
)
$tracking_event_data
);
return self::create_error_notice_and_redirect( $query_params );
}
Expand Down

0 comments on commit ea4c2cf

Please sign in to comment.