Skip to content

Commit 5ff4555

Browse files
committed
Add shortcode to get if user has a role with full content access
1 parent 998bb26 commit 5ff4555

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

plugins/bcc-login/includes/class-bcc-login-visibility.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ function __construct( BCC_Login_Settings $settings, BCC_Login_Client $client, BC
6060
add_shortcode( 'post_group_tags_widget', array( $this, 'post_group_tags_widget' ) );
6161
add_shortcode( 'get_bcc_group_name', array( $this, 'get_bcc_group_name_by_id' ) );
6262
add_shortcode( 'bcc_my_roles', array( $this, 'bcc_my_roles' ) );
63+
add_shortcode( 'has_bcc_role_with_full_content_access', array( $this, 'has_bcc_role_with_full_content_access' ) );
6364

6465
add_action( 'add_meta_boxes', array( $this, 'add_visibility_meta_box_to_attachments' ) );
6566
add_action( 'attachment_updated', array( $this, 'save_visibility_to_attachments' ), 10, 3 );
@@ -204,7 +205,7 @@ function on_template_redirect() {
204205
if ( $post_visibility ) {
205206
$visibility = $post_visibility;
206207
}
207-
}
208+
}
208209

209210
if ( $visibility && $visibility > $level ) {
210211
if ( is_user_logged_in() ) {
@@ -762,6 +763,20 @@ public function bcc_my_roles() {
762763
return json_encode($this->get_user_groups_list());
763764
}
764765

766+
public function has_bcc_role_with_full_content_access() {
767+
$user_groups = $this->get_current_user_groups();
768+
769+
if (!$user_groups) {
770+
return false;
771+
}
772+
773+
if (count(array_intersect($this->_settings->full_content_access_groups, $user_groups)) > 0) {
774+
return true;
775+
}
776+
777+
return false;
778+
}
779+
765780
/**
766781
* Checks the `bccLoginVisibility` attribute and hides the block if
767782
* the current users shouldn't be allowed to see it.

0 commit comments

Comments
 (0)