Jump to content

Subscribe to updates


Tyssen
 Share

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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;
});

 

Link to comment
Share on other sites

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/

Link to comment
Share on other sites

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)...

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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