Created
February 18, 2015 09:01
-
-
Save alroniks/b82eba16efb6db0834f8 to your computer and use it in GitHub Desktop.
Batch Subscriber for Sendex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$modx->addPackage('sendex', MODX_CORE_PATH . 'components/sendex/model/'); | |
$subscribers = array( | |
array('Фамилия Имя Отчество' , '[email protected]'), | |
); | |
foreach ($subscribers as $s) { | |
if (!$u = $modx->getObject('modUserProfile', array('email' => $s[1]))) { | |
$response = $modx->runProcessor('security/user/create', array( | |
'username' => $s[1], | |
'email' => $s[1], | |
'fullname' => $s[0], | |
'passwordnotifymethod' => 1, | |
'active' => true | |
)); | |
} | |
} | |
foreach ($subscribers as $s) { | |
if ($user = $modx->getObject('modUserProfile', array('email' => $s[1]))) { | |
$newsletter = array('newsletter_id' => 1, 'email' => $s[1], 'user_id' => $user->get('id')); | |
if (!$subscriber = $modx->getObject('sxSubscriber', $newsletter)) { | |
$subscriber = $modx->newObject('sxSubscriber'); | |
$subscriber->fromArray($newsletter); | |
$subscriber->save(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment