Documentation

GetUserGroups

array
CBlogUser::GetUserGroups(
 int    ID,
 int    blogID,
 string joinStatus = "",
 int    selectType = BLOG_BY_BLOG_USER_ID
);

The method returns an array of user groups for the blog with the blogID. The user with ID is attached to these user groups. Static method.

Method parameters

ParameterDescriptionAvailable from version
ID User ID.
blogID Blog ID.
joinStatus Flag - specifies whether a user is attached to a user group, or this attachment is still pending. Optional. By default, this status is not relevant.
selectType Specific user ID to search. Possible values:
  • BLOG_BY_USER_ID - search by the site user ID;
  • BLOG_BY_BLOG_USER_ID - search by the blog user ID.
Optional. By default BLOG_BY_BLOG_USER_ID - search by the blog user ID.
bUrl Optional parameter. Value by default - "false".

Returned value

Returns an array of blog user groups, or false otherwise.

Note

This method uses built-in caching. As a result, when the method is used multiple times on the page, the database request will be performed only once.

Examples of use

<?
// retrieve user groups for a blog with ID=1. The current user is attached to these user groups
$ID = $USER->GetID();
$arUserGroups = CBlogUser::GetUserGroups($ID, 1, "", BLOG_BY_USER_ID);
if(is_array($arUserGroups))
    print_r($arUserGroups);
?>


© «Bitrix24», 2001-2024
Up