Documentation

Add

int
CSocNetMessages::Add(
 array arFields
);

The method adds new message to a user. The message can be both personal and system. Non-static method.

Note: To add new personal message, it's recommended to use the method [link=191246]CSocNetMessages::CreateMessage[/link].
The following events are called when executing the method: [link=191899]OnBeforeSocNetMessagesAdd[/link] and [link=191912]OnSocNetMessagesAdd[/link].

Parameters

Parameter Description Available from version
arFields Array of new message parameters. Can contain the following keys:
FROM_USER_ID - message sender (required field),
TO_USER_ID - message recipient (required field),
MESSAGE - message (required field),
DATE_CREATE - date when message is created (required field),
MESSAGE_TYPE - message type: P - personal, S - system.

Returned value

The method returns the created message ID on success or false otherwise.

Examples

<?
$arFields = array( 
   "FROM_USER_ID" => 1, 
   "TO_USER_ID" => 2, 
   "MESSAGE" => "Hello!", 
   "=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(), 
   "MESSAGE_TYPE" => "P", 
); 
CSocNetMessages::Add($arFields);
?>


© «Bitrix24», 2001-2024
Up