Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add All members custom groups to filter widget #184

Merged
merged 2 commits into from
Jan 29, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions plugins/bcc-login/includes/class-bcc-login-visibility.php
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,17 @@ function filter_by_queried_target_groups($query) {
'compare' => 'IN'
);

if (in_array('all-members', $target_groups)) {
$meta_query = array(
'relation' => 'OR',
$meta_query,
array(
'key' => 'bcc_groups',
'compare' => 'NOT EXISTS'
)
);
}

// Filter by selected target groups
$query->set('meta_query', $meta_query);
}
Expand Down Expand Up @@ -832,6 +843,10 @@ function bcc_enqueue_quick_edit_scripts( $pagehook ) {
// end Quick Edit

function get_group_name($group_uid) {
if ($group_uid == 'all-members') {
return __('Alle medlemmer', 'bcc-login');
}

foreach ($this->_coreapi->get_translated_site_groups() as $group) {
if ($group->uid === $group_uid) {
return $group->name;
Expand All @@ -852,6 +867,11 @@ function target_groups_filter_widget() {
'<a href="javascript:void(0)" id="close-bcc-groups">' . __('Close', 'bcc-login') . '</a>';

$html .= '<ul>';
$html .= '<li class="bcc-checkbox-wrapper">' .
'<input type="checkbox" class="bcc-checkbox" id="all-members" value="all-members" name="target-groups[]"' . (in_array('all-members', $queried_target_groups) ? 'checked' : '') . '/>' .
'<label for="all-members">' . __( 'Alle medlemmer', 'bcc-login' ) . '</label>' .
'</li>';

foreach ($user_site_groups as $group) :
if (in_array($group->uid, $excluded_groups)) continue;

Expand Down
Loading