From 37924cc17b2f2582769245b02fd0bcb12701f9f1 Mon Sep 17 00:00:00 2001 From: Joaquim d'Souza Date: Wed, 8 Nov 2023 12:35:39 +0100 Subject: [PATCH] feat: add hide user checkbox and disable wpml notifications by default --- web/app/themes/awasqa/src/authors.php | 19 +++++++++++++++++++ .../awasqa/src/carbon-fields-blocks.php | 4 ++++ web/app/themes/awasqa/src/carbon-fields.php | 9 +++++++++ web/app/themes/awasqa/src/wpml.php | 5 +++++ 4 files changed, 37 insertions(+) diff --git a/web/app/themes/awasqa/src/authors.php b/web/app/themes/awasqa/src/authors.php index d725a57..2f1aa0a 100644 --- a/web/app/themes/awasqa/src/authors.php +++ b/web/app/themes/awasqa/src/authors.php @@ -289,8 +289,19 @@ function extra_admin_user_fields($user) ); $cols = $wpdb->get_col($sql); $string_id = $cols[0] ?? ""; + $hide_user = (bool) get_user_meta($user_id, 'awasqa-hide-user', true); + $hide_user_checked = $hide_user ? 'checked="checked"' : ''; ?>

Awasqa

+ + + + + +
Ocultar Autor + > + +
@@ -326,6 +337,10 @@ function awasqa_save_admin_user_fields($user_id) if (current_user_can('edit_user', $user_id)) { handle_update_profile_pic($user_id); + // Hide author + $hide_user = $_POST['awasqa-hide-user'] ?? 0; + update_user_meta($user_id, 'awasqa-hide-user', $hide_user); + // Add translated bio $spanish_description = $_POST['description'] ?? null; $string_id = $_POST['form-translated-bio-string-id'] ?? null; @@ -389,3 +404,7 @@ function get_translated_author_bio($author_id, $lang = null) $translations = icl_get_string_translations_by_id($string_id[0]); return $translations[$lang]['value'] ?? $description; } + +add_filter('coauthors_edit_author_cap', function ($capabilities) { + return 'read'; +}); diff --git a/web/app/themes/awasqa/src/carbon-fields-blocks.php b/web/app/themes/awasqa/src/carbon-fields-blocks.php index bf8f5dc..effcaf1 100644 --- a/web/app/themes/awasqa/src/carbon-fields-blocks.php +++ b/web/app/themes/awasqa/src/carbon-fields-blocks.php @@ -213,6 +213,10 @@ function get_issue_options() $authors_data = []; foreach ($user_ids as $author_id) { $meta = get_user_meta($author_id); + $hide_user = (bool) get_user_meta($author_id, 'awasqa-hide-user', true); + if ($hide_user) { + continue; + } $image_id = $meta['awasqa_profile_pic_id'][0] ?? null; $image_url = $image_id ? wp_get_attachment_image_src($image_id) : null; $name = Awasqa\Authors\awasqa_get_author_name($author_id); diff --git a/web/app/themes/awasqa/src/carbon-fields.php b/web/app/themes/awasqa/src/carbon-fields.php index c4a3537..e5b8cb7 100644 --- a/web/app/themes/awasqa/src/carbon-fields.php +++ b/web/app/themes/awasqa/src/carbon-fields.php @@ -120,3 +120,12 @@ function add_user_to_organisation($org_id, $user_id) \Carbon_Fields\Carbon_Fields::boot(); }); + +add_filter('carbon_fields_association_field_options_members_user', function ($args) { + $search_term = $args['search'] ?? ''; + if (!$search_term) { + return $args; + } + $args['search'] = '*' . $search_term . '*'; + return $args; +}); diff --git a/web/app/themes/awasqa/src/wpml.php b/web/app/themes/awasqa/src/wpml.php index 65375de..9f45ad7 100644 --- a/web/app/themes/awasqa/src/wpml.php +++ b/web/app/themes/awasqa/src/wpml.php @@ -249,3 +249,8 @@ function connect_translations_page() 3 ); }); + +// Disable WPML notifications by default +add_action('user_register', function ($user_id, $userdata) { + update_user_meta($user_id, \WPML_User_Jobs_Notification_Settings::BLOCK_NEW_NOTIFICATION_FIELD, 1); +}, 10, 2);