Closed jvanremoortere closed 7 years ago
Can't seem to get it to work...
public function boot()
{
// Register recipient groups for newsletter
if (class_exists('\Backend\Models\User')) {
$this->reverseExtendBackendUser();
}
}
protected function reverseExtendBackendUser()
{
Event::listen('responsiv.campaign.listRecipientGroups', function() {
return [
'backend-users-all' => 'All backend users',
];
});
Event::listen('responsiv.campaign.getRecipientsData', function($type) {
if ($type == 'backend-users-all') {
$result = [];
$allBackendUsers = \Backend\Models\User::all();
foreach ($allBackendUsers as $user) {
$result[$user->email] = ['first_name' => $user->first_name, 'last_name' => $user->last_name];
}
return $result;
}
});
}
Looks fine, where are you registering this code?
In my Plugin.php of my plugin...
Works great over here!
Yes ok. That part works for me too... But for some reason I always get the "Oops! It looks like your campaign hasn't got any subscribers... You can restore this campaign and try launching it again." error when trying to send a campaign to that group.
Ok. Added this to another project and seems to work just fine there. I will have to check everything else getting called in my boot...
Is it possible to reverse extend the Backend User like you extend the RainLab.User in the plugin?