<!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>[BuddyPress][10801] branches/2.5: Better hash building for activation keys, password reset keys, and filenames.</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 { 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://buddypress.trac.wordpress.org/changeset/10801">10801</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://buddypress.trac.wordpress.org/changeset/10801","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>boonebgorges</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2016-05-24 14:45:08 +0000 (Tue, 24 May 2016)</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'>Better hash building for activation keys, password reset keys, and filenames.

There is no need to use user-facing info for these hashes.

Ports <a href="http://buddypress.trac.wordpress.org/changeset/10800">[10800]</a> to the 2.5 branch.

Props DJPaul, vortfu.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branches25srcbpcoreclassesclassbpattachmentavatarphp">branches/2.5/src/bp-core/classes/class-bp-attachment-avatar.php</a></li>
<li><a href="#branches25srcbpcoreclassesclassbpattachmentcoverimagephp">branches/2.5/src/bp-core/classes/class-bp-attachment-cover-image.php</a></li>
<li><a href="#branches25srcbpmembersbpmembersfunctionsphp">branches/2.5/src/bp-members/bp-members-functions.php</a></li>
<li><a href="#branches25srcbpmembersbpmembersscreensphp">branches/2.5/src/bp-members/bp-members-screens.php</a></li>
<li><a href="#branches25srcbpmembersclassesclassbpsignupphp">branches/2.5/src/bp-members/classes/class-bp-signup.php</a></li>
<li><a href="#branches25srcbpsettingsbpsettingsactionsphp">branches/2.5/src/bp-settings/bp-settings-actions.php</a></li>
<li><a href="#branches25testsphpunittestcasesmembersfunctionsphp">branches/2.5/tests/phpunit/testcases/members/functions.php</a></li>
</ul>

<h3>Property Changed</h3>
<ul>
<li><a href="#branches25">branches/2.5/</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<span class="cx" style="display: block; padding: 0 10px">Index: branches/2.5
</span><span class="cx" style="display: block; padding: 0 10px">===================================================================
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">--- branches/2.5 2016-05-24 14:34:37 UTC (rev 10800)
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+++ branches/2.5  2016-05-24 14:45:08 UTC (rev 10801)
</ins><a id="branches25"></a>
<div class="propset"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Property changes: branches/2.5</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svnmergeinfo"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: svn:mergeinfo</h4></div>
<span class="cx" style="display: block; padding: 0 10px"> /branches/1.5:5187,5203,5210-5216,5220,5225,5247,5635
</span><span class="cx" style="display: block; padding: 0 10px"> /branches/2.4:10363
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/trunk:10800
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="branches25srcbpcoreclassesclassbpattachmentavatarphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: branches/2.5/src/bp-core/classes/class-bp-attachment-avatar.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- branches/2.5/src/bp-core/classes/class-bp-attachment-avatar.php   2016-05-24 14:34:37 UTC (rev 10800)
+++ branches/2.5/src/bp-core/classes/class-bp-attachment-avatar.php     2016-05-24 14:45:08 UTC (rev 10801)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -292,7 +292,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                $args['dst_h'] = bp_core_avatar_full_height();
</span><span class="cx" style="display: block; padding: 0 10px">                        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        $args['dst_file'] = $avatar_folder_dir . '/' . wp_hash( $absolute_path . time() ) . '-bp' . $key_type . '.' . $ext;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 $filename         = wp_unique_filename( $avatar_folder_dir, uniqid() . "-bp{$key_type}.{$ext}" );
+                       $args['dst_file'] = $avatar_folder_dir . '/' . $filename;
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                        $avatar_types[ $key_type ] = parent::crop( $args );
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span></span></pre></div>
<a id="branches25srcbpcoreclassesclassbpattachmentcoverimagephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: branches/2.5/src/bp-core/classes/class-bp-attachment-cover-image.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- branches/2.5/src/bp-core/classes/class-bp-attachment-cover-image.php      2016-05-24 14:34:37 UTC (rev 10800)
+++ branches/2.5/src/bp-core/classes/class-bp-attachment-cover-image.php        2016-05-24 14:45:08 UTC (rev 10801)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -208,12 +208,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        return false;
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $info    = pathinfo( $file );
-               $dir     = $info['dirname'];
-               $ext     = strtolower( $info['extension'] );
-               $name    = wp_hash( $file . time() ) . '-bp-cover-image';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $info = pathinfo( $file );
+               $ext  = strtolower( $info['extension'] );
+               $name = wp_unique_filename( $info['dirname'], uniqid() . "-bp-cover-image.$ext" );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                return trailingslashit( $dir ) . "{$name}.{$ext}";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         return trailingslashit( $info['dirname'] ) . $name;
</ins><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">        /**
</span></span></pre></div>
<a id="branches25srcbpmembersbpmembersfunctionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: branches/2.5/src/bp-members/bp-members-functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- branches/2.5/src/bp-members/bp-members-functions.php      2016-05-24 14:34:37 UTC (rev 10800)
+++ branches/2.5/src/bp-members/bp-members-functions.php        2016-05-24 14:45:08 UTC (rev 10801)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1791,7 +1791,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                // Format data.
</span><span class="cx" style="display: block; padding: 0 10px">                $user_login     = preg_replace( '/\s+/', '', sanitize_user( $user_login, true ) );
</span><span class="cx" style="display: block; padding: 0 10px">                $user_email     = sanitize_email( $user_email );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $activation_key = substr( md5( time() . rand() . $user_email ), 0, 16 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $activation_key = wp_generate_password( 32, false );
</ins><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">                 * WordPress's default behavior is to create user accounts
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1813,7 +1813,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                return $user_id;
</span><span class="cx" style="display: block; padding: 0 10px">                        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        $activation_key = wp_hash( $user_id );
</del><span class="cx" style="display: block; padding: 0 10px">                         bp_update_user_meta( $user_id, 'activation_key', $activation_key );
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1937,13 +1936,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $user_id = username_exists( $signup->user_login );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // Create the user.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         // Create the user. This should only be necessary if BP_SIGNUPS_SKIP_USER_CREATION is true.
</ins><span class="cx" style="display: block; padding: 0 10px">                 if ( ! $user_id ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        $user_id = wp_create_user( $signup->user_login, $password, $signup->user_email );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // If a user ID is found, this may be a legacy signup, or one
-               // created locally for backward compatibility. Process it.
-               } elseif ( $key == wp_hash( $user_id ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         // Otherwise, update the existing user's status.
+               } elseif ( $key === bp_get_user_meta( $user_id, 'activation_key', true ) || $key === wp_hash( $user_id ) ) {
+
</ins><span class="cx" style="display: block; padding: 0 10px">                         // Change the user's status so they become active.
</span><span class="cx" style="display: block; padding: 0 10px">                        if ( ! $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET user_status = 0 WHERE ID = %d", $user_id ) ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                                return new WP_Error( 'invalid_key', __( 'Invalid activation key.', 'buddypress' ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2103,7 +2102,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // Rebuild the activation key, if missing.
</span><span class="cx" style="display: block; padding: 0 10px">                if ( empty( $signup->activation_key ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        $signup->activation_key = wp_hash( $signup->ID );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 $signup->activation_key = wp_generate_password( 32, false );
</ins><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">                if ( bp_is_active( 'xprofile' ) ) {
</span></span></pre></div>
<a id="branches25srcbpmembersbpmembersscreensphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: branches/2.5/src/bp-members/bp-members-screens.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- branches/2.5/src/bp-members/bp-members-screens.php        2016-05-24 14:34:37 UTC (rev 10800)
+++ branches/2.5/src/bp-members/bp-members-screens.php  2016-05-24 14:45:08 UTC (rev 10801)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -359,14 +359,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        bp_core_redirect( trailingslashit( bp_get_root_domain() . '/' . $bp->pages->activate->slug ) );
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $hashed_key = wp_hash( $key );
-
-               // Check if the signup avatar folder exists. If it does, move the folder to
-               // the BP user avatars directory.
-               if ( file_exists( bp_core_avatar_upload_path() . '/avatars/signups/' . $hashed_key ) ) {
-                       @rename( bp_core_avatar_upload_path() . '/avatars/signups/' . $hashed_key, bp_core_avatar_upload_path() . '/avatars/' . $user );
-               }
-
</del><span class="cx" style="display: block; padding: 0 10px">                 bp_core_add_message( __( 'Your account is now active!', 'buddypress' ) );
</span><span class="cx" style="display: block; padding: 0 10px">                $bp->activation_complete = true;
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span></span></pre></div>
<a id="branches25srcbpmembersclassesclassbpsignupphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: branches/2.5/src/bp-members/classes/class-bp-signup.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- branches/2.5/src/bp-members/classes/class-bp-signup.php   2016-05-24 14:34:37 UTC (rev 10800)
+++ branches/2.5/src/bp-members/classes/class-bp-signup.php     2016-05-24 14:45:08 UTC (rev 10801)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -736,7 +736,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                foreach ( $signups as $signup ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        $user_id = username_exists( $signup->user_login );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        if ( ! empty( $user_id ) && $signup->activation_key == wp_hash( $user_id ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 if ( ! empty( $user_id ) && $signup->activation_key === bp_get_user_meta( $user_id, 'activation_key', true ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                                if ( 2 != self::check_user_status( $user_id ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span></span></pre></div>
<a id="branches25srcbpsettingsbpsettingsactionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: branches/2.5/src/bp-settings/bp-settings-actions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- branches/2.5/src/bp-settings/bp-settings-actions.php      2016-05-24 14:34:37 UTC (rev 10800)
+++ branches/2.5/src/bp-settings/bp-settings-actions.php        2016-05-24 14:45:08 UTC (rev 10801)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -94,7 +94,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                                // Store a hash to enable email validation.
</span><span class="cx" style="display: block; padding: 0 10px">                                if ( false === $email_error ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        $hash = wp_hash( $_POST['email'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 $hash = wp_generate_password( 32, false );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                                        $pending_email = array(
</span><span class="cx" style="display: block; padding: 0 10px">                                                'hash'     => $hash,
</span></span></pre></div>
<a id="branches25testsphpunittestcasesmembersfunctionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: branches/2.5/tests/phpunit/testcases/members/functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- branches/2.5/tests/phpunit/testcases/members/functions.php        2016-05-24 14:34:37 UTC (rev 10800)
+++ branches/2.5/tests/phpunit/testcases/members/functions.php  2016-05-24 14:45:08 UTC (rev 10801)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -261,7 +261,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $u_obj = new WP_User( $u );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // Fake an old-style registration
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $key = wp_hash( $u_obj->ID );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $key = wp_generate_password( 32, false );
</ins><span class="cx" style="display: block; padding: 0 10px">                 update_user_meta( $u, 'activation_key', $key );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                global $wpdb;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -295,7 +295,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $u_obj = new WP_User( $u );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // Fake an old-style registration
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $key = wp_hash( $u_obj->ID );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $key = wp_generate_password( 32, false );
</ins><span class="cx" style="display: block; padding: 0 10px">                 update_user_meta( $u, 'activation_key', $key );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // ...but ensure that user_status is 0. This mimics the
</span></span></pre>
</div>
</div>

</body>
</html>