Skip to content

Commit

Permalink
feat: add hide user checkbox and disable wpml notifications by default
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquimds committed Nov 8, 2023
1 parent bbe3d18 commit f72ef4a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
15 changes: 15 additions & 0 deletions web/app/themes/awasqa/src/authors.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"' : '';
?>
<h2>Awasqa</h2>
<table class="form-table">
<tr>
<th>Ocultar Autor</th>
<td>
<input id="awasqa-hide-user" type="checkbox" name="awasqa-hide-user" value="1" <?= $hide_user_checked ?>>
<label for="awasqa-hide-user">Ocultar Autor</label>
</td>
</tr>
</table>
<table class="form-table">
<tr>
<th><label for="translated-bio"><?= __('Bio en Ingles', 'awasqa') ?></label></th>
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions web/app/themes/awasqa/src/carbon-fields-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions web/app/themes/awasqa/src/wpml.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

0 comments on commit f72ef4a

Please sign in to comment.