Documentation

CForumMessage::Add

int
Add(
 array arFields [,
 string strUploadDir]
);

The method Add adds a new message. Returns the ID of the created message.

Parameters

ParameterDescription
arFields An array of the format Array(field1=>value1[, field2=>value2 [, ..]]), where

field - field name;
value - field value.

Fields are listed in the List of message fields. The required fields must be filled.
strUploadDir Directory in which files are to be uploaded. Must be specified relative to the main upload directory.
Optional. The default value is "forum".

Return Values

Returns the ID of the created message on success, or false by default.

See Also

  • Message fields
  • Before a message is created, you should check whether it can be added using CForumMessage::CanUserAddMessage. It is recommended to add and modify messages and message subjects using the method ForumAddMessage.

    Example


    
    <?
    $arFields = Array(
      "POST_MESSAGE" => $POST_MESSAGE,
      "USE_SMILES" => ($USE_SMILES=="Y") ? "Y" : "N",
      "APPROVED" => $APPROVED
      "AUTHOR_NAME" => $AUTHOR_NAME,
      "AUTHOR_ID" => $AUTHOR_ID,
      "FORUM_ID" => $FID,
      "TOPIC_ID" => $TID,
      "AUTHOR_IP" => ($AUTHOR_IP!==False) ? $AUTHOR_IP : "<no address>",
      "NEW_TOPIC" => "N"
    );
    $ID = CForumMessage::Add($arFields);
    if (IntVal($ID)<=0)
      echo "Error!";
    ?>
    
  • © «Bitrix24», 2001-2024
    Up