CSubcription::Add( $arFields, $SITE_ID=SITE_ID );
The method Add adds a subscription and sends the message containing the subscription confirmation code to the subscriber unless he has chosen not to receive such messages.
Parameter | Description |
---|---|
$arFields | Associated array containing the keys and values of Subscription
object fields. The following fields can also be used:
|
$SITE_ID | The ID of the site used to determine the template of the subscription confirmation message. The parameter has the default value of the current site ID. |
Returns the subscription ID on success. In case of an error, it returns false and the class variable LAST_ERROR contains the error description.
//there must be at least one newsletter category if(!is_array($RUB_ID) || count($RUB_ID) == 0) $strWarning .= "There must be at least one category."."<br>"; if($strWarning == "") { $arFields = Array( "USER_ID" => ($USER->IsAuthorized()? $USER->GetID():false), "FORMAT" => ($FORMAT <> "html"? "text":"html"), "EMAIL" => $EMAIL, "ACTIVE" => "Y", "RUB_ID" => $RUB_ID ); //can add without authorization $ID = $subscr->Add($arFields); if($ID>0) CSubscription::Authorize($ID); else $strWarning .= "Error adding subscription: ".$subscr->LAST_ERROR."<br>"; }
© 2001-2005 Bitrix | Bitrix Site Manager - Content Management & Portal Solutions |