source/Application/Model/User.php
public function setNewsSubscription($blSubscribe, $blSendOptIn, $blForceCheckOptIn = false)
    {
        // assigning to newsletter
        $blSuccess = false;

        // user wants to get newsletter messages or no ?
        $oNewsSubscription = $this->getNewsSubscription();
        if ($oNewsSubscription) {
            if ($blSubscribe && ($blForceCheckOptIn || ($iOptInStatus = $oNewsSubscription->getOptInStatus()) != 1)) {
                if (!$blSendOptIn) {
                    // double-opt-in check is disabled - assigning automatically
                    $this->addToGroup('oxidnewsletter');
                    // and setting subscribed status
                    $oNewsSubscription->setOptInStatus(1);
                    $blSuccess = true;
                } else {
                    // double-opt-in check enabled - sending confirmation email and setting waiting status
                    if ($iOptInStatus != 2) {
                        // sending double-opt-in mail
                        $oEmail = oxNew(\OxidEsales\Eshop\Core\Email::class);
                        $blSuccess = $oEmail->sendNewsletterDbOptInMail($this);
                    } else {
                        // mail already was sent, so just confirming that
                        $blSuccess = true;
                    }

                    $oNewsSubscription->setOptInStatus(2);
                }
            } elseif (!$blSubscribe) {
                // removing user from newsletter subscribers
                $this->removeFromGroup('oxidnewsletter');
                $oNewsSubscription->setOptInStatus(0);
                $blSuccess = true;
            }
        }

        return $blSuccess;
    }
public function setNewsSubscription($blSubscribe, $blSendOptIn, $blForceCheckOptIn = false)
    {
        // assigning to newsletter
        $blSuccess = false;

        // user wants to get newsletter messages or no ?
        $oNewsSubscription = $this->getNewsSubscription();
        if ($oNewsSubscription) {
            if ($blSubscribe && ($blForceCheckOptIn || ($iOptInStatus = $oNewsSubscription->getOptInStatus()) != 1)) {
                if (!$blSendOptIn) {
                    // double-opt-in check is disabled - assigning automatically
                    $this->addToGroup('oxidnewsletter');
                    // and setting subscribed status
                    $oNewsSubscription->setOptInStatus(1);
                    $blSuccess = true;
                } else {
                    // double-opt-in check enabled - sending confirmation email and setting waiting status
                    if ($iOptInStatus != 2) {
                        // sending double-opt-in mail
                        $oEmail = oxNew(\OxidEsales\Eshop\Core\Email::class);
                        $blSuccess = $oEmail->sendNewsletterDbOptInMail($this);
                    } else {
                        // mail already was sent, so just confirming that
                        $blSuccess = true;
                    }

                    $oNewsSubscription->setOptInStatus(2);
                }
            } elseif (!$blSubscribe) {
                // removing user from newsletter subscribers
                $this->removeFromGroup('oxidnewsletter');
                $oNewsSubscription->setOptInStatus(0);
                $blSuccess = true;
            }
        }

        return $blSuccess;
    }
public function setNewsSubscription ( $ blSubscribe , $ blSendOptIn , $ blForceCheckOptIn = false ) { // assigning to newsletter $ blSuccess = false ; // user wants to get newsletter messages or no ? $ oNewsSubscription = $ this -> getNewsSubscription ( ) ; if ( $ oNewsSubscription ) { if ( $ blSubscribe && ( $ blForceCheckOptIn || ( $ iOptInStatus = $ oNewsSubscription -> getOptInStatus ( ) ) != 1 ) ) { if ( ! $ blSendOptIn ) { // double-opt-in check is disabled - assigning automatically $ this -> addToGroup ( 'oxidnewsletter' ) ; // and setting subscribed status $ oNewsSubscription -> setOptInStatus ( 1 ) ; $ blSuccess = true ; } else { // double-opt-in check enabled - sending confirmation email and setting waiting status if ( $ iOptInStatus != 2 ) { // sending double-opt-in mail $ oEmail = oxNew ( \ OxidEsales \ Eshop \ Core \ Email :: class ) ; $ blSuccess = $ oEmail -> sendNewsletterDbOptInMail ( $ this ) ; } else { // mail already was sent, so just confirming that $ blSuccess = true ; } $ oNewsSubscription -> setOptInStatus ( 2 ) ; } } elseif ( ! $ blSubscribe ) { // removing user from newsletter subscribers $ this -> removeFromGroup ( 'oxidnewsletter' ) ; $ oNewsSubscription -> setOptInStatus ( 0 ) ; $ blSuccess = true ; } } return $ blSuccess ; }
Sets newsletter subscription status to user

@param bool $blSubscribe       subscribes/unsubscribes user from newsletter
@param bool $blSendOptIn       if to send confirmation email
@param bool $blForceCheckOptIn forces to check subscription even when it is set to 1

@return bool
Sets newsletter subscription status to user