<!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>[12749] sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc: Support Forums: Improve the user notes for role changes to include the previous non-participant role, capture moderator/spectator role sets, and generally have cleaner code.</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/12749">12749</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/12749","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>2023-07-20 04:01:22 +0000 (Thu, 20 Jul 2023)</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'>Support Forums: Improve the user notes for role changes to include the previous non-participant role, capture moderator/spectator role sets, and generally have cleaner code.
See <a href="http://meta.trac.wordpress.org/ticket/5707">#5707</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginssupportforumsincclassauditlogphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-audit-log.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginssupportforumsincclasshooksphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-hooks.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginssupportforumsincclassauditlogphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-audit-log.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-audit-log.php 2023-07-18 06:01:31 UTC (rev 12748)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-audit-log.php 2023-07-20 04:01:22 UTC (rev 12749)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,6 +1,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> namespace WordPressdotorg\Forums;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+use WP_User;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> class Audit_Log {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -11,13 +12,30 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> var $edited_notes = [];
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Keeps track of the role changes for each user.
+ *
+ * @var array
+ */
+ var $last_role_change = [];
+
</ins><span class="cx" style="display: block; padding: 0 10px"> function __construct() {
</span><span class="cx" style="display: block; padding: 0 10px"> // Audit-log entries for Term subscriptions (add/remove)
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_action( 'wporg_bbp_add_user_term_subscription', array( $this, 'term_subscriptions' ), 10, 2 );
- add_action( 'wporg_bbp_remove_user_term_subscription', array( $this, 'term_subscriptions' ), 10, 2 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_action( 'wporg_bbp_add_user_term_subscription', [ $this, 'term_subscriptions' ], 10, 2 );
+ add_action( 'wporg_bbp_remove_user_term_subscription', [ $this, 'term_subscriptions' ], 10, 2 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Add a user note for forum role changes.
+ add_action( 'add_user_role', [ $this, 'monitor_role_changes' ], 10, 2 );
+ add_action( 'remove_user_role', [ $this, 'monitor_role_changes' ], 10, 2 );
+ add_filter( 'bbp_set_user_role', [ $this, 'bbp_set_user_role' ], 10, 3 );
+
+ // Add a user note when flagging/unflagging a user.
+ add_action( 'wporg_bbp_flag_user', [ $this, 'log_user_flag_changes' ], 10, 1 );
+ add_action( 'wporg_bbp_unflag_user', [ $this, 'log_user_flag_changes' ], 10, 1 );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Slack logs for Moderation notes.
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'wporg_bbp_note_added', [ $this, 'forums_notes_added' ], 10, 2 );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_action( 'shutdown', [ $this, 'forums_notes_added_shutdown' ] );
</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 class="lines" style="display: block; padding: 0 10px; color: #888">@@ -50,7 +68,90 @@
</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">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Keep track of the role changes that happen via bbp_set_user_role.
+ *
+ * TODO: Check if this is still needed, bbPress might pass context via bbp_set_user_role.
+ */
+ function monitor_role_changes( $user_id, $role ) {
+ $this->last_role_change[ $user_id ] ??= [];
+ $this->last_role_change[ $user_id ][ current_filter() ] = $role;
+ }
+
+ /**
+ * Monitor for role changes, and log as appropriate.
+ *
+ * NOTE: This is also triggered on Locale forums. We may need to revisit that at some point.
+ */
+ function bbp_set_user_role( $new_role, $user_id, WP_User $user ) {
+ $previous_role = $this->last_role_change[ $user_id ][ 'remove_user_role' ] ?? false;
+
+ // For the purposes of this function, a previous participant role is irrelevant.
+ if ( bbp_get_participant_role() == $previous_role ) {
+ $previous_role = false;
+ }
+
+ $monitored_roles = [
+ bbp_get_keymaster_role(),
+ bbp_get_moderator_role(),
+ // bbp_get_participant_role(), // Not monitoring for changes involving only this role.
+ bbp_get_spectator_role(),
+ bbp_get_blocked_role()
+ ];
+
+ if (
+ // If the role change is not one we're monitoring, bail.
+ ! array_intersect( $monitored_roles, [ $new_role, $previous_role ] ) ||
+ // If we can't detect any change, bail.
+ $new_role === $previous_role
+ ) {
+ return $new_role; // We're on a filter.
+ }
+
+ // Determine what triggered this change.
+ $where_from = ! ms_is_switched() ? home_url( '/' ) : $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
+ $where_from = explode( '?', $where_from )[0];
+ $where_from = preg_replace( '!^(?:https?://)?(.+?)/?[^/]*$!i', '$1', $where_from );
+
+ // Add a user note about this action.
+ $note_text = sprintf(
+ 'Forum role changed to %s%s%s.',
+ get_role( $new_role )->name,
+ $previous_role ? sprintf( ' from %s', get_role( $previous_role )->name ) : '',
+ $where_from ? sprintf( ' via %s', $where_from ) : ''
+ );
+
+ // Used in wporg-login to add context.
+ $note_text = apply_filters( 'wporg_bbp_forum_role_changed_note_text', $note_text, $user );
+
+ // Add a user note about this action.
+ Plugin::get_instance()->user_notes->add_user_note_or_update_previous(
+ $user->ID,
+ $note_text
+ );
+
+ // It's a filter, so we need to return the value.
+ return $new_role;
+ }
+
+ /**
+ * Add a user note when a user is flagged / unflagged.
+ *
+ * @param int $user_id
+ */
+ function log_user_flag_changes( $user_id ) {
+ $flag_action = ( 'wporg_bbp_flag_user' === current_action() ) ? 'flagged' : 'unflagged';
+
+ $note_text = "User {$flag_action}.";
+
+ Plugin::get_instance()->user_notes->add_user_note_or_update_previous(
+ $user_id,
+ $note_text
+ );
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Record Note changes to Slack.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param int $user_id
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -59,10 +160,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function forums_notes_added( $user_id, $note_id ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->edited_notes[ $user_id ] ??= [];
</span><span class="cx" style="display: block; padding: 0 10px"> $this->edited_notes[ $user_id ][] = $note_id;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
- if ( ! has_action( 'shutdown', [ $this, 'forums_notes_added_shutdown' ] ) ) {
- add_action( 'shutdown', [ $this, 'forums_notes_added_shutdown' ] );
- }
</del><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 class="lines" style="display: block; padding: 0 10px; color: #888">@@ -69,7 +166,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Send Slack notifications for Note changes.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function forums_notes_added_shutdown() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! function_exists( 'notify_slack' ) || ! defined( 'FORUMS_MODACTIONS_SLACK_CHANNEL' ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! $this->edited_notes || ! function_exists( 'notify_slack' ) || ! defined( 'FORUMS_MODACTIONS_SLACK_CHANNEL' ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return;
</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="sitestrunkwordpressorgpublic_htmlwpcontentpluginssupportforumsincclasshooksphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-hooks.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-hooks.php 2023-07-18 06:01:31 UTC (rev 12748)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-hooks.php 2023-07-20 04:01:22 UTC (rev 12749)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -135,13 +135,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Don't embed WordPress.org links with anchors included.
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'pre_oembed_result', array( $this, 'pre_oembed_result_dont_embed_wordpress_org_anchors' ), 20, 2 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Add a user note when flagging/unflagging a user.
- add_filter( 'wporg_bbp_flag_user', array( $this, 'log_user_flag_changes' ) );
- add_filter( 'wporg_bbp_unflag_user', array( $this, 'log_user_flag_changes' ) );
-
</del><span class="cx" style="display: block; padding: 0 10px"> // Break users sessions / passwords when they get blocked, on the main forums only.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( 'wordpress.org' === get_blog_details()->domain ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_action( 'bbp_set_user_role', array( $this, 'user_blocked_password_handler' ), 10, 3 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_filter( 'bbp_set_user_role', array( $this, 'user_blocked_password_handler' ), 10, 3 );
</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 class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1359,6 +1355,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Catch a user being blocked / unblocked and set their password appropriately.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * Note: This method is called even when the users role is not changed.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
+ * See Audit_Log class for where the note is set/updated.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function user_blocked_password_handler( $new_role, $user_id, \WP_User $user ) {
</span><span class="cx" style="display: block; padding: 0 10px"> global $wpdb;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1365,7 +1363,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // ~~~ is a reset password on WordPress.org. Let's ignore those.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( '~~~' === $user->user_pass ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return $new_role;
</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"> // bbPress 1.x used `{$user_pass}---{$secret}` while we're using the reverse here.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1373,24 +1371,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $blocked_prefix = 'BLOCKED' . substr( wp_hash( 'bb_break_password' ), 0, 13 ) . '---';
</span><span class="cx" style="display: block; padding: 0 10px"> $blocked_role = bbp_get_blocked_role();
</span><span class="cx" style="display: block; padding: 0 10px"> $password_broken = ( 0 === strpos( $user->user_pass, $blocked_prefix ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $note_text = false;
</del><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // WP_User::has_role() does not exist, and WP_User::has_cap( 'bbp_blocked' ) will be truthful for super admins.
</span><span class="cx" style="display: block; padding: 0 10px"> $user_has_blocked_role = ! empty( $user->roles ) && in_array( $blocked_role, $user->roles, true );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Define what has blocked the user.
- if ( ! ms_is_switched() ) {
- $where_from = preg_replace( '!^https?://!i', '', home_url( is_admin() ? '/wp-admin' : '' ) );
- } else {
- // When we're switched, we can't determine the source of the switch, so we use a bit of URL parsing magic.
- $where_from = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
- if ( str_contains( $where_from, '?' ) ) {
- list( $where_from, ) = explode( '?', $where_from );
- }
- // Trim actual filename off, just the major path component.
- $where_from = preg_replace( '!/[^/?]+\.[a-z]{3}$!i', '', $where_from );
- }
-
</del><span class="cx" style="display: block; padding: 0 10px"> if (
</span><span class="cx" style="display: block; padding: 0 10px"> ( $blocked_role === $new_role || $user_has_blocked_role ) &&
</span><span class="cx" style="display: block; padding: 0 10px"> ! $password_broken
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1412,16 +1396,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Destroy all of their WordPress sessions.
</span><span class="cx" style="display: block; padding: 0 10px"> $manager = \WP_Session_Tokens::get_instance( $user->ID );
</span><span class="cx" style="display: block; padding: 0 10px"> $manager->destroy_all();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
- // Add a user note about this action.
- $note_text = sprintf(
- $where_from ? 'Forum role changed to %s via %s.' : 'Forum role changed to %s.',
- get_role( $new_role )->name,
- $where_from
- );
-
- // Used in wporg-login to add context.
- $note_text = apply_filters( 'wporg_bbp_forum_role_changed_note_text', $note_text, $user );
</del><span class="cx" style="display: block; padding: 0 10px"> } else if (
</span><span class="cx" style="display: block; padding: 0 10px"> $password_broken &&
</span><span class="cx" style="display: block; padding: 0 10px"> ! $user_has_blocked_role
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1439,39 +1413,10 @@
</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"> clean_user_cache( $user );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
- // Add a user note about this action.
- $note_text = sprintf(
- $where_from ? 'Forum role changed to %s via %s.' : 'Forum role changed to %s.',
- get_role( $new_role )->name,
- $where_from
- );
-
- // Unused, here for consistency with above.
- $note_text = apply_filters( 'wporg_bbp_forum_role_changed_note_text', $note_text, $user );
</del><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">- if ( $note_text ) {
- // Add a user note about this action.
- Plugin::get_instance()->user_notes->add_user_note_or_update_previous(
- $user->ID,
- $note_text
- );
- }
-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // It's a filter, return the value.
+ return $new_role;
</ins><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">- /**
- * Add a user note when a user is flagged / unflagged.
- */
- function log_user_flag_changes( $user_id ) {
- $flag_action = ( 'wporg_bbp_flag_user' === current_filter () ) ? 'flagged' : 'unflagged';
-
- $note_text = "User {$flag_action}.";
-
- Plugin::get_instance()->user_notes->add_user_note_or_update_previous(
- $user_id,
- $note_text
- );
- }
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre>
</div>
</div>
</body>
</html>