Support » Plugin: Subscribe2 » Subscribe2 sends email immediately when scheduling future posts

  • Resolved dtweney


    I’m using Subscribe2 (version 8.4) to send emails when posts are published. It’s been working swimmingly for several years to publish scheduled posts.

    However, today I installed another plugin, Publish to Schedule. This plugin automatically picks a future date, so there is only one post per day, and schedules a post for a random time on that day.

    Problem: When I press the “publish to schedule” button, it schedules the post for the randomly-selected future date — but Subscribe2 sends out an email immediately.

    Is there a way to fix this?

Viewing 3 replies - 1 through 3 (of 3 total)
  • @dtweney,

    Having had a brief look at the code for the Publish to Schedule it seems that it allows the post to be published first (thus allowing Subscribe2 to send) and then changes the posts date and status back to future again, this will probably mean Subscribe2 will actually send 2 notifications, one at the time when you hit “Publish to Schedule” and one again when the post actually becomes visible on your site.

    I cannot think immediately of a way to make these 2 plugins work together that I could use in the core code without breaking things for others. If you really want to use them both together you could try commenting out some of the Subscribe2 code.

    Look in the classes/class-s2-core.php file for these lines:

    add_action('new_to_publish', array(&$this, 'publish'));
    add_action('draft_to_publish', array(&$this, 'publish'));
    add_action('auto-draft_to_publish', array(&$this, 'publish'));
    add_action('pending_to_publish', array(&$this, 'publish'));
    add_action('private_to_publish', array(&$this, 'publish'));
    add_action('future_to_publish', array(&$this, 'publish'));

    Comment out all of those lines with the exception of the last one:

    //add_action('new_to_publish', array(&$this, 'publish'));
    //add_action('draft_to_publish', array(&$this, 'publish'));
    //add_action('auto-draft_to_publish', array(&$this, 'publish'));
    //add_action('pending_to_publish', array(&$this, 'publish'));
    //add_action('private_to_publish', array(&$this, 'publish'));
    add_action('future_to_publish', array(&$this, 'publish'));

    This will make sure that Subscribe2 only sends posts for future posts.

    Holy cow, MattyRob, you’ve gone above and beyond in finding the source of this problem. That’s exactly it — thanks for sleuthing this out!

    In light of this problem I’ve decided not to use Publish to Schedule. That just seems like a weird way of doing things and likely to cause problems in other ways besides confusing Subscribe2.

    Instead, I found another plugin, draft scheduler, which lets me do something similar. I’m using that one instead.

    Thanks very much for your help!

    Also: Issue resolved!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Subscribe2 sends email immediately when scheduling future posts’ is closed to new replies.