diff --git a/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-users.php b/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-users.php
index e9a6fbb56..501b3c4d4 100644
a
|
b
|
|
2 | 2 | |
3 | 3 | namespace WordPressdotorg\Forums; |
4 | 4 | |
| 5 | use WordPressdotorg\Forums\User_Moderation\Plugin as User_Moderation; |
| 6 | |
5 | 7 | class Users { |
6 | 8 | |
7 | 9 | public function __construct() { |
… |
… |
class Users { |
9 | 11 | add_action( 'bbp_user_edit_after_name', array( $this, 'add_custom_title_input' ) ); |
10 | 12 | add_action( 'bbp_user_edit_after', array( $this, 'add_options_section_header' ), 0 ); |
11 | 13 | add_action( 'bbp_user_edit_after', array( $this, 'add_auto_topic_subscription_checkbox' ) ); |
| 14 | add_action( 'bbp_user_edit_after', array( $this, 'add_modwatch_checkbox' ) ); |
12 | 15 | |
13 | 16 | // Save custom field values. |
14 | 17 | add_action( 'personal_options_update', array( $this, 'save_custom_fields' ), 10, 2 ); |
… |
… |
class Users { |
113 | 116 | <?php |
114 | 117 | } |
115 | 118 | |
| 119 | /** |
| 120 | * Add a modwatch checkbox to user's profile. |
| 121 | */ |
| 122 | public function add_modwatch_checkbox() { |
| 123 | // Only show to moderators. |
| 124 | if ( ! current_user_can( 'moderate' ) ) { |
| 125 | return; |
| 126 | } |
| 127 | |
| 128 | $user_id = bbp_get_user_id(); |
| 129 | |
| 130 | $modwatch = ( new User_Moderation() )->is_user_flagged( $user_id ); |
| 131 | ?> |
| 132 | <p> |
| 133 | <input name="flag_user_modwatch" id="flag_user_modwatch" type="checkbox" value="yes" <?php checked( $modwatch ); ?> /> |
| 134 | <label for="flag_user_modwatch"><?php esc_html_e( 'Flag this user for moderation', 'wporg-forums' ); ?></label> |
| 135 | </p> |
| 136 | <?php |
| 137 | } |
| 138 | |
116 | 139 | /** |
117 | 140 | * Save custom field values. |
118 | 141 | * |
… |
… |
class Users { |
125 | 148 | |
126 | 149 | $auto_topic_subscription = isset( $_POST['auto_topic_subscription'] ); |
127 | 150 | update_user_option( $user_id, 'auto_topic_subscription', $auto_topic_subscription ); |
| 151 | |
| 152 | // Flag user for moderation. |
| 153 | if ( current_user_can( 'moderate' ) && isset( $_POST['flag_user_modwatch'] ) ) { |
| 154 | $modwatch = ( new User_Moderation() )->is_user_flagged( $user_id ); |
| 155 | if ( ! $modwatch ) { |
| 156 | ( new User_Moderation() )->flag_user( $user_id ); |
| 157 | } |
| 158 | } else { |
| 159 | ( new User_Moderation() )->unflag_user( $user_id ); |
| 160 | } |
128 | 161 | } |
129 | 162 | |
130 | 163 | public function modify_user_fields( $value, $field, $filter ) { |