@@ -1048,23 +1048,40 @@ function post_group_tags_widget($atts) {
10481048 $ post_id = get_the_ID ();
10491049 if (!$ post_id ) return false ;
10501050
1051- $ attributes = shortcode_atts (array ('limit ' => 100 , 'with_link ' => true ), $ atts );
1051+ $ attributes = shortcode_atts (
1052+ array (
1053+ 'limit ' => 100 ,
1054+ 'with_link ' => true ,
1055+ 'only_user_groups ' => false
1056+ ),
1057+ $ atts
1058+ );
1059+
1060+ // Convert to actual booleans
1061+ $ only_user_groups = filter_var ($ attributes ['only_user_groups ' ], FILTER_VALIDATE_BOOLEAN );
1062+ $ with_link = filter_var ($ attributes ['with_link ' ], FILTER_VALIDATE_BOOLEAN );
10521063
10531064 $ post_groups = get_post_meta ($ post_id , 'bcc_groups ' , false );
10541065 $ filtering_groups = $ this ->_settings ->filtering_groups ;
1055- $ shown_groups = array_slice (array_intersect ($ post_groups , $ filtering_groups ), 0 , $ attributes ['limit ' ]);
1066+ $ shown_groups = array_intersect ($ post_groups , $ filtering_groups );
1067+
1068+ if ($ only_user_groups ) {
1069+ $ user_groups = $ this ->get_current_user_groups ();
1070+ $ shown_groups = array_intersect ($ shown_groups , $ user_groups );
1071+ }
1072+
1073+ $ shown_groups = array_slice ($ shown_groups , 0 , $ attributes ['limit ' ]);
10561074
10571075 $ html = '' ;
10581076
10591077 foreach ($ shown_groups as $ group ) {
1060- $ link = $ attributes [ ' with_link ' ] == true ? '/informasjon/?target-groups[]= ' . $ group : 'javascript:void(0) ' ;
1078+ $ link = $ with_link ? '/informasjon/?target-groups[]= ' . $ group : 'javascript:void(0) ' ;
10611079 $ html .= '<a class="bcc-badge bcc-badge-sm bcc-badge-custom" href=" ' . $ link . '"><i class="material-symbols-rounded">info</i><span> ' . $ this ->get_group_name ($ group ) . '</span></a> ' ;
10621080 }
10631081
10641082 return $ html ;
10651083 }
10661084
1067-
10681085 function tags_for_queried_target_groups () {
10691086 $ html = '' ;
10701087
0 commit comments