Developing a Social Network on 1C-Bitrix
A social network is one of the most complex types of web applications in terms of database load. Activity feeds, subscriptions, likes, comments, real-time notifications — each of these features requires non-trivial architectural decisions. 1C-Bitrix has a built-in Social Network module (socialnetwork) that covers a significant portion of the basic functionality. The question is how deep the required customisation goes.
The Built-in socialnetwork Module
The socialnetwork module is included in the "Business" edition and higher. It provides:
- User groups (not to be confused with access groups) — analogous to communities.
- Live feed (
b_sonet_log,b_sonet_log_right,b_sonet_log_event). - Subscription system (
b_sonet_subscription). - Messages (
b_sonet_message). - Contacts/friends (
b_sonet_relations). - Workgroups.
If the built-in module's functionality is sufficient — use it without reinventing the wheel. If deep UI/UX customisation or non-standard logic is required — build on top of it or alongside it.
User Profile
An extended user profile — via UF fields (custom fields on the b_user_field table). Added in the admin area or programmatically:
$userType = new \CUserTypeEntity();
$userType->Add([
'ENTITY_ID' => 'USER',
'FIELD_NAME' => 'UF_AVATAR_FULL',
'USER_TYPE_ID' => 'file',
'XML_ID' => 'UF_AVATAR_FULL',
'SORT' => 100,
'MULTIPLE' => 'N',
'MANDATORY' => 'N',
'SHOW_FILTER' => 'N',
'SHOW_IN_LIST' => 'N',
'EDIT_IN_LIST' => 'Y',
'IS_SEARCHABLE' => 'N',
'SETTINGS' => ['EXTENSIONS' => 'jpg,jpeg,png,gif,webp'],
'EDIT_FORM_LABEL' => ['ru' => 'Фото профиля', 'en' => 'Profile photo'],
]);
Typical UF profile fields for a social network: UF_ABOUT, UF_CITY, UF_WEBSITE, UF_SOCIAL_VK, UF_SOCIAL_TG, UF_INTERESTS (multiple).
Activity Feed
The built-in Bitrix live feed is a good foundation. But for a custom social network a different feed generation algorithm is usually needed. Two approaches:
Pull model (simple). The user opens the feed — a DB query collects events from everyone they follow:
// Get IDs of users the current user follows
$subscriptions = \Bitrix\Socialnetwork\UserToUserTable::getList([
'filter' => [
'FROM_USER_ID' => $currentUserId,
'RELATION' => \Bitrix\Socialnetwork\UserToUserTable::RELATION_SUBSCRIBED,
],
'select' => ['TO_USER_ID'],
])->fetchAll();
$followedIds = array_column($subscriptions, 'TO_USER_ID');
$followedIds[] = $currentUserId; // Own posts also in the feed
// Get posts
$posts = FeedPostTable::getList([
'filter' => ['AUTHOR_ID' => $followedIds, 'IS_DELETED' => false],
'order' => ['CREATED_AT' => 'DESC'],
'limit' => 20,
'offset' => $page * 20,
])->fetchAll();
Push model (scalable). When a post is published — add a record to the b_local_feed_{userId} table for each follower. The user's feed = their personal table. Expensive on write, fast on read. For large audiences (1000+ followers per author) — a hybrid scheme.
Posts and Content
HL block for posts:
class FeedPostTable extends \Bitrix\Main\ORM\Data\DataManager
{
public static function getTableName(): string { return 'b_hl_social_post'; }
public static function getMap(): array
{
return [
new IntegerField('ID', ['primary' => true, 'autocomplete' => true]),
new IntegerField('AUTHOR_ID'),
new TextField('CONTENT'), // Post text
new StringField('CONTENT_TYPE'), // text | html
new BooleanField('IS_DELETED', ['values' => [false, true]]),
new IntegerField('LIKES_COUNT'),
new IntegerField('COMMENTS_COUNT'),
new IntegerField('REPOSTS_COUNT'),
new DatetimeField('CREATED_AT'),
new DatetimeField('UPDATED_AT'),
new StringField('PRIVACY'), // public | friends | private
];
}
}
Media attachments to posts — a separate table b_hl_social_post_media with fields: POST_ID, TYPE (image/video/file), FILE_ID (reference to b_file), SORT.
Likes and Reactions
The built-in socialnetwork module has the b_rating_vote table for likes. It is better to use it rather than building your own — Bitrix automatically displays like counters in its interfaces.
// Place a like via the rating module API
\Bitrix\Main\Loader::includeModule('rating');
$rating = new \CRating('BLOG_COMMENT', $postId, $authorId);
$rating->Like($currentUserId, 1);
If reactions are needed (❤️, 😂, 😮) — a separate table b_hl_social_reactions with a reaction type field.
Real-time Notifications
For notifications without page reload — two options:
Long polling. The client periodically (every 10–30 seconds) asks the server about new notifications. Simple to implement, works everywhere.
WebSocket via Bitrix Push Server. In corporate Bitrix24 installations, Push & Pull Server is available — a WebSocket server. Integration via the JS module BX.PullClient.
BX.ready(() => {
BX.PullClient.subscribe({
moduleId: 'local.social',
callback: (data) => {
if (data.command === 'new_notification') {
showNotification(data.params);
updateNotificationCounter();
}
}
});
});
On the server when an event occurs (like, comment, subscription):
\Bitrix\Pull\Event::add($targetUserId, [
'module_id' => 'local.social',
'command' => 'new_notification',
'params' => [
'type' => 'like',
'from_user' => $fromUserId,
'entity_id' => $postId,
'message' => $fromUserName . ' liked your post',
],
]);
\Bitrix\Pull\Event::send();
Subscription System
Follower-author relationships — via \Bitrix\Socialnetwork\UserToUserTable or a custom table. Important states: subscribed, subscription pending (for private accounts), blocked.
Development Timelines
| Option | Composition | Duration |
|---|---|---|
| Based on socialnetwork | Profiles, groups, feed — via built-in module | 15–25 days |
| Custom social network | Posts, subscriptions, likes, notifications, custom feed | 40–60 days |
| Full platform | + Messenger, stories, recommendation system | 80–120 days |







