Jump to content

Recommended Posts

Posted

Does anything exist within PW for people to be able to subscribe to updates? So you enter your email address and when new blog posts are published, you get an email alert? And I guess there also needs to be a way for people to unsubscribe too.

Does anything exist like that for PW?

Posted

I can see that you can use the module to add subscribers to a Mailchimp list, but it seems like you could just use a Mailchimp form to do that. I'm not seeing anything in there about there being a link between publishing content in Processwire and then subscribers receiving emails about that event.

Posted
21 minutes ago, Tyssen said:

I'm not seeing anything in there about there being a link between publishing content in Processwire and then subscribers receiving emails about that event.

I see. There seems to be nothing presently that suits your needs then (but others can chime in). If that's the case, you can roll your own. A most basic one would consist of two parts. 

  1. Publishing a post: A hook to monitor this event (e.g. in ready.php) should do the trick. You could send the emails right within the hook. How and when you do it depends on how many emails you have to send.
  2. Subscribe/Unsubscribe: There is a module, I think for email subscriptions? If not you would have to store this somewhere. Ryan wrote about this somewhere, how he does it with ProcessWire weekly newsletters. I think they are just pages.
Posted

Maybe the ProMailer can help out?

Quote

ProMailer is the ideal tool for creating and sending email newsletters and managing subscribers in ProcessWire.

 

  • Like 2
Posted

So would that still be using a webhook as described in #1 by @kongondo above and using ProMailer for #2? Or does the triggering of emails when pages are published exist in ProMailer already?

Posted

So in ready.php it would be something like this?

wire()->addHookAfter('Pages::published', function($event) {
    $page = $event->arguments('page');

    $t = wire()->templates->get($page->template);
    if($t->name == 'blog') {
        // what goes here?
    }   
    $event->return = $page;
});

 

Posted

Something like this...

wire()->addHookAfter('Pages::published', function($event) {    
 	$page = $event->arguments(0);
    if($page->template !='blog-post' ) return;
	// ProMailer API TO SEND EMAILS 
   	// no need to return $event if you haven't modified it
});

Talk to Ryan about ProMailer API if what you need does not exist here

https://processwire.com/api/ref/pro-mailer/

Posted

Depending on the situation (how many subscribers etc) this could be really simple to implement on your own:

  1. A form that subscribes an email to the current page (using $page->meta('subscribers') for example)
  2. A hook that sends an email on every publish of a child of the subscribed page (using WireMail)
  3. A magic link in every email to unsubscribe (eg unsubscribe section or unsubscribe all)

It get's more complicated of course if you got a larger number of subscribers or you need to deal with legal stuff (opt-in, mail confirmation links etc) - but sometimes simple solutions are totally fine (eg if you only have a handful of trusted users)...

Posted

@bernhard Presumably the hook for #2 could look the same as the one @kongondo wrote above? It doesn't necessarily need to be a child of a particular page, but instead match a template. And for #3, what would the magic link look like, how would it be generated?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...