PluginProbe ʕ •ᴥ•ʔ
Atarim – Visual Feedback, Review & AI Collaboration / 5.0
Atarim – Visual Feedback, Review & AI Collaboration v5.0
5.0 trunk 3.10 3.11 3.12 3.13 3.14 3.15 3.16 3.17 3.18 3.19 3.2.0 3.2.1 3.22 3.22.1 3.22.2 3.22.3 3.22.4 3.22.5 3.22.6 3.3.0 3.3.1 3.3.2 3.3.2.1 3.3.2.2 3.3.3 3.30 3.31 3.32 3.4 3.4.1 3.4.3 3.4.4 3.5 3.5.1 3.6 3.6.1 3.7 3.8 3.9 3.9.1 3.9.2 3.9.3 3.9.4 3.9.6 3.9.6.1 4.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.0.9 4.1.0 4.1.1 4.1.2 4.1.3 4.2 4.2.1 4.2.2 4.3 4.3.1 4.3.2 4.3.3 4.3.4 4.3.5 4.4
atarim-visual-collaboration / admin / class-user-meta.php
atarim-visual-collaboration / admin Last commit date
atarim-connect-screen.php 2 weeks ago class-avcf-offboarding.php 2 weeks ago class-avcf-settings.php 2 weeks ago class-avcf-upgrade-notice.php 2 weeks ago class-user-meta.php 2 weeks ago
class-user-meta.php
62 lines
1 <?php
2 if (!defined('ABSPATH')) {
3 exit;
4 }
5
6 class AVCF_User_Meta {
7 public function __construct() {
8 // Display checkbox
9 add_action('show_user_profile', [$this, 'add_webmaster_checkbox']);
10 add_action('edit_user_profile', [$this, 'add_webmaster_checkbox']);
11
12 // Save checkbox
13 add_action('personal_options_update', [$this, 'save_webmaster_checkbox']); // admin editing self
14 add_action('edit_user_profile_update', [$this, 'save_webmaster_checkbox']); // admin editing others
15 }
16
17 /**
18 * Add the "Webmaster" checkbox to the user profile screen.
19 *
20 * @param WP_User $user
21 */
22 public function add_webmaster_checkbox($user) {
23 // Only admins can see this
24 if (!current_user_can('administrator')) {
25 return;
26 }
27
28 $checked = get_user_meta($user->ID, 'avc_user_type', true) === 'webmaster' ? 'checked' : '';
29 ?>
30 <h3><?php esc_html_e('Custom User Settings', 'atarim-visual-collaboration'); ?></h3>
31 <table class="form-table" role="presentation">
32 <tr>
33 <th><label for="avc_user_type"><?php esc_html_e('Webmaster', 'atarim-visual-collaboration'); ?></label></th>
34 <td>
35 <input type="checkbox" name="avc_user_type" id="avc_user_type" value="webmaster" <?php echo $checked; ?> />
36 <label for="avc_user_type"><?php esc_html_e('Make this user webmaster', 'atarim-visual-collaboration'); ?></label>
37 </td>
38 </tr>
39 </table>
40 <?php
41 }
42
43 /**
44 * Save the "Webmaster" checkbox value.
45 *
46 * @param int $user_id
47 */
48 public function save_webmaster_checkbox($user_id) {
49 // Only admins can save
50 if (!current_user_can('administrator')) {
51 return;
52 }
53
54 if (isset($_POST['avc_user_type']) && sanitize_text_field(wp_unslash($_POST['avc_user_type'])) === 'webmaster') {
55 update_user_meta($user_id, 'avc_user_type', 'webmaster');
56 } else {
57 delete_user_meta($user_id, 'avc_user_type');
58 }
59 }
60 }
61
62 new AVCF_User_Meta();