Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Newsletter Module


Reply


18 Posts   2237 Views

Avatar
Rossel

Community Member, 18 Posts

13 February 2012 at 10:21pm

Edited: 13/02/2012 10:33pm

Try taking a look in your database at the groups table it will show you what id your newsletter group is.

Your "Page not found" error is, Im guessing, because i was redirecting everyone who was not a member to my signup page, which you don't have, see this line:

return Director::redirect($this->Link("/sign-up/?s=1&e=" . $email));


You should be able to just add them to your newsletter group if you don't want them to have to become a member first.

try this or something like it instead:

function doSubscribeForm($data, $form){
   $email = Convert::raw2sql($data['Email']); // prevent sql injection

   //check if newsletter exists first
   if($newsletter_group = DataObject::get_one('Group', "ID = 4")):
      if($existing_member = DataObject::get_one("Member", "Email = '$email'")):
         $member = $this->CurrentMember();
         //If current member matches the existing member.
         if($member->ID == $existing_member->ID):
            $existing_member->Groups()->add($newsletter_group);
         else:
            return Director::redirect(Director::BaseURL() . 'Security/login');
         endif;
            return Director::redirectBack();
      else:
         //create new member and add them to newsletter group
         $member = new Member();
         $form->saveInto($member);
         $member->write();
         $member->Groups()->add($newsletter_group);
      endif;
   endif;
   return Director::redirectBack();
}

Avatar
benni91

Community Member, 72 Posts

14 February 2012 at 7:18am

Edited: 14/02/2012 7:38am

Ok :) now the form adds the address to the newsletter module. But, after adding an mail there's no success message.
And after adding the functions my jquery image slider crashes. the console says

/termine/?flush=1:31 Uncaught TypeError: Cannot call method 'css' of null
jquery.load.slider.js:2 Uncaught TypeError: Cannot call method 'nivoSlider' of null

what's that?!

Regards Benni

EDIT:// Found something which should fix it. This jQuery.noConflict thing.
But after Adding this. The Subscriberform doesn't work. It just redirects to /security and doesn't give the mail to the module