<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[11823] sites/trunk/api.wordpress.org/public_html/dotorg/helpscout: HelpScout: Show the correct user details for bounced emails.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://meta.trac.wordpress.org/changeset/11823">11823</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://meta.trac.wordpress.org/changeset/11823","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>dd32</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2022-05-10 04:03:43 +0000 (Tue, 10 May 2022)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>HelpScout: Show the correct user details for bounced emails.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#sitestrunkapiwordpressorgpublic_htmldotorghelpscoutcommonphp">sites/trunk/api.wordpress.org/public_html/dotorg/helpscout/common.php</a></li>
<li><a href="#sitestrunkapiwordpressorgpublic_htmldotorghelpscoutdpophp">sites/trunk/api.wordpress.org/public_html/dotorg/helpscout/dpo.php</a></li>
<li><a href="#sitestrunkapiwordpressorgpublic_htmldotorghelpscoutforumsphp">sites/trunk/api.wordpress.org/public_html/dotorg/helpscout/forums.php</a></li>
<li><a href="#sitestrunkapiwordpressorgpublic_htmldotorghelpscoutpluginsthemesphp">sites/trunk/api.wordpress.org/public_html/dotorg/helpscout/plugins-themes.php</a></li>
<li><a href="#sitestrunkapiwordpressorgpublic_htmldotorghelpscoutprofilephp">sites/trunk/api.wordpress.org/public_html/dotorg/helpscout/profile.php</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#sitestrunkapiwordpressorgpublic_htmldotorghelpscoutclasshelpscoutphp">sites/trunk/api.wordpress.org/public_html/dotorg/helpscout/class-helpscout.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkapiwordpressorgpublic_htmldotorghelpscoutclasshelpscoutphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/api.wordpress.org/public_html/dotorg/helpscout/class-helpscout.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/api.wordpress.org/public_html/dotorg/helpscout/class-helpscout.php (rev 0)
+++ sites/trunk/api.wordpress.org/public_html/dotorg/helpscout/class-helpscout.php 2022-05-10 04:03:43 UTC (rev 11823)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,84 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+namespace WordPressdotorg\API\HelpScout;
+
+/**
+ * Simple HelpScout client.
+ *
+ * @see WordPressdotorg\Plugin_Directory\Clients
+ */
+class API {
+ const API_BASE = 'https://api.helpscout.net';
+
+ /**
+ * The HTTP timeout for the HelpScout API.
+ */
+ const TIMEOUT = 5;
+
+ public static function api( $url, $args = null, $method = 'GET' ) {
+ // Verify the configuration variables are available.
+ if ( ! defined( 'HELPSCOUT_APP_ID' ) || ! defined( 'HELPSCOUT_APP_SECRET' ) ) {
+ return false;
+ }
+
+ // Prepend API URL host-less URLs
+ if ( ! str_starts_with( $url, self::API_BASE ) ) {
+ $url = self::API_BASE . '/' . ltrim( $url, '/' );
+ }
+
+ if ( 'GET' === $method && $args ) {
+ $url = add_query_arg( $args, $url );
+ }
+
+ $request = wp_remote_request(
+ $url,
+ array(
+ 'method' => $method,
+ 'headers' => [
+ 'Accept' => 'application/json',
+ 'Authorization' => self::get_auth_string(),
+ ],
+ 'timeout' => self::TIMEOUT,
+ 'body' => ( 'POST' === $method && $args ) ? $args : null,
+ )
+ );
+
+ return json_decode( wp_remote_retrieve_body( $request ) );
+ }
+
+ /**
+ * Fetch an Authorization token for accessing HelpScout Resources.
+ */
+ protected static function get_auth_string() {
+ $token = get_site_transient( __CLASS__ . 'get_auth_token' );
+ if ( $token && is_array( $token ) && $token['exp'] > time() ) {
+ return 'BEARER ' . $token['token'];
+ }
+
+ $request = wp_remote_post(
+ self::API_BASE . '/v2/oauth2/token',
+ array(
+ 'timeout' => self::TIMEOUT,
+ 'body' => array(
+ 'grant_type' => 'client_credentials',
+ 'client_id' => HELPSCOUT_APP_ID,
+ 'client_secret' => HELPSCOUT_APP_SECRET
+ )
+ )
+ );
+
+ $response = is_wp_error( $request ) ? false : json_decode( wp_remote_retrieve_body( $request ) );
+
+ if ( ! $response || empty( $response->access_token ) ) {
+ return false;
+ }
+
+ // Cache the token for 1 minute less than what it's valid for.
+ $token = $response->access_token;
+ $expiry = $response->expires_in - MINUTE_IN_SECONDS;
+
+ set_site_transient( __CLASS__ . 'get_auth_token', [ 'exp' => time() + $expiry, 'token' => $token ], $expiry );
+
+ return 'BEARER ' . $token;
+ }
+
+}
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: sites/trunk/api.wordpress.org/public_html/dotorg/helpscout/class-helpscout.php
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="sitestrunkapiwordpressorgpublic_htmldotorghelpscoutcommonphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/api.wordpress.org/public_html/dotorg/helpscout/common.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/api.wordpress.org/public_html/dotorg/helpscout/common.php 2022-05-05 08:34:20 UTC (rev 11822)
+++ sites/trunk/api.wordpress.org/public_html/dotorg/helpscout/common.php 2022-05-10 04:03:43 UTC (rev 11823)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,9 +1,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+use WordPressdotorg\API\HelpScout\API as Helpscout_API;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-$wp_init_host = 'https://wordpress.org/';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+$wp_init_host = 'https://api.wordpress.org/';
</ins><span class="cx" style="display: block; padding: 0 10px"> $base_dir = dirname( dirname( __DIR__ ) );
</span><span class="cx" style="display: block; padding: 0 10px"> require( $base_dir . '/wp-init.php' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+include_once __DIR__ . '/class-helpscout.php';
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // function to verify signature from HelpScout
</span><span class="cx" style="display: block; padding: 0 10px"> function isFromHelpScout($data, $signature) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! defined( 'HELPSCOUT_SECRET_KEY' ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -15,6 +18,69 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return hash_equals( $signature, $calculated );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+function get_user_email_for_email( $request ) {
+ $email = $request->customer->email ?? false;
+ $subject = $request->ticket->subject ?? '';
+ $user = get_user_by( 'email', $email );
+
+ // Ignore @wordpress.org "users", unless it's literally the only match (The ?? $email fallback at the end).
+ if ( $user && str_ends_with( $user->user_email, '@wordpress.org' ) ) {
+ $user = false;
+ }
+
+ // If this is related to a slack user, fetch their details instead.
+ if (
+ false !== stripos( $email, 'slack' ) &&
+ preg_match( '/(\S+)@chat.wordpress.org/i', $subject, $m )
+ ) {
+ $user = get_user_by( 'slug', $m[1] );
+ }
+
+ // Determine if this is a bounce, and if so, find out who for.
+ if ( ! $user && $email && isset( $request->ticket->id ) ) {
+ $from = strtolower( $email . ' ' . ( $request->customer->fname ?? '' ) . ' ' . $request->customers->lname );
+ if (
+ str_contains( $from, 'mail delivery' ) ||
+ str_contains( $from, 'postmaster' ) ||
+ str_contains( strtolower( $subject ), 'undelivered mail' ) ||
+ str_contains( strtolower( $subject ), 'returned to sender')
+ ) {
+ // Fetch the email.
+ $email_obj = Helpscout_API::api( '/v2/conversations/' . $request->ticket->id . '?embed=threads' );
+ if ( ! empty( $email_obj->_embedded->threads ) ) {
+ foreach ( $email_obj->_embedded->threads as $thread ) {
+ if ( 'customer' !== $thread->type ) {
+ continue;
+ }
+
+ // Extract emails from the mailer-daemon.
+ $email_body = strip_tags( str_replace( '<br>', "\n", $thread->body ) );
+
+ // Extract `To:`, `X-Orig-To:`, and fallback to all emails.
+ $emails = [];
+ if ( preg_match( '!^(x-orig-to:|to:)\s*(.+@.+)$!im', $email_body, $m ) ) {
+ $emails = [ trim( $m[2], '<> ' ) ];
+ } else {
+ // Ugly regex for emails, but it's good for mailer-daemon emails.
+ if ( preg_match_all( '![^\s;"]+@[^\s;&"]+\.[^\s;&"]+!', $email_body, $m ) ) {
+ $emails = array_unique( array_diff( $m[0], [ $request->mailbox->email ] ) );
+ }
+ }
+
+ foreach ( $emails as $maybe_email ) {
+ $user = get_user_by( 'email', $maybe_email );
+ if ( $user ) {
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return $user->user_email ?? $email;
+}
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // HelpScout sends json data in the POST, so grab it from the input directly
</span><span class="cx" style="display: block; padding: 0 10px"> $data = file_get_contents( 'php://input' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -30,18 +96,4 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // get the info from HS
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-$data = json_decode( $data );
-
-// If this is related to a slack user, fetch their details instead.
-if (
- isset ( $data->customer->email, $data->ticket->subject ) &&
- false !== stripos( $data->customer->email, 'slack' ) &&
- preg_match( '/(\S+)@chat.wordpress.org/i', $data->ticket->subject, $m )
-) {
- $user = get_user_by( 'slug', $m[1] );
- if ( $user ) {
- $data->customer->email = $user->user_email;
- }
-}
-
-return $data;
</del><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of file
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+return json_decode( $data );
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of file
</span></span></pre></div>
<a id="sitestrunkapiwordpressorgpublic_htmldotorghelpscoutdpophp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/api.wordpress.org/public_html/dotorg/helpscout/dpo.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/api.wordpress.org/public_html/dotorg/helpscout/dpo.php 2022-05-05 08:34:20 UTC (rev 11822)
+++ sites/trunk/api.wordpress.org/public_html/dotorg/helpscout/dpo.php 2022-05-10 04:03:43 UTC (rev 11823)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -13,7 +13,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // default empty output
</span><span class="cx" style="display: block; padding: 0 10px"> $html = '';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-$email = $request->customer->email;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+$email = get_user_email_for_email( $request );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $html .= sprintf(
</span><span class="cx" style="display: block; padding: 0 10px"> "<p>Search <a href='%s'>Erasures</a> | <a href='%s'>Exports</a></p>",
</span></span></pre></div>
<a id="sitestrunkapiwordpressorgpublic_htmldotorghelpscoutforumsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/api.wordpress.org/public_html/dotorg/helpscout/forums.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/api.wordpress.org/public_html/dotorg/helpscout/forums.php 2022-05-05 08:34:20 UTC (rev 11822)
+++ sites/trunk/api.wordpress.org/public_html/dotorg/helpscout/forums.php 2022-05-10 04:03:43 UTC (rev 11823)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -5,9 +5,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $request = include __DIR__ . '/common.php';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // default empty output
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-$html = '';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+$html = '';
</ins><span class="cx" style="display: block; padding: 0 10px"> // look up profile url by email
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-$user = get_user_by( 'email', $request->customer->email );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+$email = get_user_email_for_email( $request );
+$user = get_user_by( 'email', $email );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Include Notes
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $user && $user->_wporg_bbp_user_notes ) {
</span></span></pre></div>
<a id="sitestrunkapiwordpressorgpublic_htmldotorghelpscoutpluginsthemesphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/api.wordpress.org/public_html/dotorg/helpscout/plugins-themes.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/api.wordpress.org/public_html/dotorg/helpscout/plugins-themes.php 2022-05-05 08:34:20 UTC (rev 11822)
+++ sites/trunk/api.wordpress.org/public_html/dotorg/helpscout/plugins-themes.php 2022-05-10 04:03:43 UTC (rev 11823)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6,8 +6,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // default empty output
</span><span class="cx" style="display: block; padding: 0 10px"> $html = '';
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> // look up profile url by email
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-$user = get_user_by( 'email', $request->customer->email );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+$email = get_user_email_for_email( $request );
+$user = get_user_by( 'email', $email );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! $user ) {
</span><span class="cx" style="display: block; padding: 0 10px"> echo json_encode( array( 'html' => $html ) );
</span><span class="cx" style="display: block; padding: 0 10px"> die();
</span></span></pre></div>
<a id="sitestrunkapiwordpressorgpublic_htmldotorghelpscoutprofilephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/api.wordpress.org/public_html/dotorg/helpscout/profile.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/api.wordpress.org/public_html/dotorg/helpscout/profile.php 2022-05-05 08:34:20 UTC (rev 11822)
+++ sites/trunk/api.wordpress.org/public_html/dotorg/helpscout/profile.php 2022-05-10 04:03:43 UTC (rev 11823)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -7,12 +7,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // default empty output
</span><span class="cx" style="display: block; padding: 0 10px"> $html = '';
</span><span class="cx" style="display: block; padding: 0 10px"> $user = false;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+$email = get_user_email_for_email( $request );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Look up a user based on email address
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-if ( isset ( $request->customer->email ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+if ( $email ) {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // look up profile url by email
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user = get_user_by( 'email', $request->customer->email );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user = get_user_by( 'email', $email );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $user->user_nicename ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $html .= '<p>Profile: <a href="https://profiles.wordpress.org/' . $user->user_nicename . '/">'. $user->user_nicename .'</a></p>';
</span><span class="cx" style="display: block; padding: 0 10px"> $html .= '<p>Forums: <a href="https://wordpress.org/support/users/'. $user->user_nicename . '/">'. $user->user_nicename .'</a></p>';
</span></span></pre>
</div>
</div>
</body>
</html>