@@ -63,6 +63,7 @@ function __construct( BCC_Login_Settings $settings, BCC_Login_Client $client, BC
6363 add_shortcode ( 'tags_for_queried_target_groups ' , array ( $ this , 'tags_for_queried_target_groups ' ) );
6464 add_shortcode ( 'get_bcc_group_name ' , array ( $ this , 'get_bcc_group_name_by_id ' ) );
6565 add_shortcode ( 'get_number_of_user_groups ' , array ( $ this , 'get_number_of_user_groups ' ) );
66+ add_shortcode ( 'bcc_my_roles ' , array ( $ this , 'bcc_my_roles ' ) );
6667
6768 add_action ( 'add_meta_boxes ' , array ( $ this , 'add_visibility_meta_box_to_attachments ' ) );
6869 add_action ( 'attachment_updated ' , array ( $ this , 'save_visibility_to_attachments ' ), 10 , 3 );
@@ -386,7 +387,6 @@ function on_block_editor_assets() {
386387 );
387388
388389 if (!empty ($ this ->_settings ->site_groups ) ) {
389-
390390 wp_add_inline_script (
391391 $ script_handle ,
392392 'var siteGroups = ' . json_encode ($ this ->_coreapi ->get_translated_site_groups ()),
@@ -401,7 +401,6 @@ function on_block_editor_assets() {
401401 }
402402
403403 if (!empty ($ this ->_settings ->site_group_tags ) ) {
404-
405404 wp_add_inline_script (
406405 $ script_handle ,
407406 'var siteGroupTags = ' . json_encode ($ this ->_settings ->site_group_tags ),
@@ -697,6 +696,52 @@ public function get_number_of_user_groups() {
697696 return count ($ this ->get_user_bcc_filtering_groups_list ());
698697 }
699698
699+ public function bcc_my_roles () {
700+ $ user_groups = $ this ->get_current_user_groups ();
701+ $ central_groups = $ this ->_settings ->filtering_groups ;
702+ $ site_groups = $ this ->_coreapi ->get_translated_site_groups ();
703+ $ central_user_groups = array ();
704+
705+ foreach ($ site_groups as $ site_group ) {
706+ if (in_array ($ site_group ->uid , $ user_groups )
707+ && in_array ($ site_group ->uid , $ central_groups )
708+ ) {
709+ $ central_user_groups [] = $ site_group ;
710+ }
711+ }
712+
713+ // Sort by name
714+ usort ($ central_user_groups , fn ($ a , $ b ) => $ a ->name <=> $ b ->name );
715+
716+ if (empty ($ central_user_groups )) {
717+ return '' ;
718+ }
719+
720+ $ html = '<div id="my-roles-widget"> ' ;
721+
722+ $ html .= '<section class="roles-list"> ' ;
723+ $ html .= '<span> ' . (count ($ central_user_groups ) == 1
724+ ? __ ('Min rolle: ' , 'bcc-login ' )
725+ : __ ('Mine roller: ' , 'bcc-login ' )
726+ ) . '</span> ' ;
727+ $ html .= '<div class="my-roles-tags"> ' ;
728+
729+ foreach ($ central_user_groups as $ group ) {
730+ $ html .= '<a class="bcc-badge bcc-badge-sm bcc-badge-custom" href="?target-groups[]= ' . $ group ->uid . '"><i class="material-symbols-rounded">info</i><span> ' . $ group ->name . '</span></a> ' ;
731+ }
732+
733+ $ html .= '</div> ' ;
734+ $ html .= '</section> ' ;
735+
736+ $ html .= '<section class="local-church-roles"> ' ;
737+ $ html .= '<a href="https://members.bcc.no/roles" target="_blank"> ' . __ ('Roller i min lokalmenighet ' , 'bcc-login ' ) . '</a> ' ;
738+ $ html .= '</section> ' ;
739+
740+ $ html .= '</div> ' ;
741+
742+ return $ html ;
743+ }
744+
700745 /**
701746 * Checks the `bccLoginVisibility` attribute and hides the block if
702747 * the current users shouldn't be allowed to see it.
0 commit comments