• Resolved mtpultz

    (@mtpultz)


    Hi, great plugin. I was looking for a bit of functionality surrounding scheduled posts being published. I changed the “publish_status” hook, which is deprecated in email-subscribers.php to “transition_post_status”. This hook provides additional parameters to es_prepare_notification() regarding pre/post status, which allows for the removal of $_POST status variables. I placed my solution below in case you’re interested. Cheers Marty

    PS never used SVN, just GIT, otherwise I’d have made a pull request after making the changes myself

    ./email-subscribers.php:line 48

    /**
     * Fix for Publishing Scheduled Posts
     * publish_post action is deprecated requires change to transition_post_status for potential future wp releases
     * @see http://codex.wordpress.org/Plugin_API/Action_Reference/publish_post (DEPRECATED)
     * @see http://codex.wordpress.org/Post_Status (Reference for different post status)
     * @see http://codex.wordpress.org/Post_Status_Transitions (SOLUTION with example of implementation)
     */
    // Original deprecated hook
    //add_action( 'publish_post', array( 'es_cls_sendmail', 'es_prepare_notification' ) ); 
    
    // New hook which returns status and post id
    add_action( 'transition_post_status', array( 'es_cls_sendmail', 'es_prepare_notification' ), 10, 3 );

    ./classes/es-sendmail.php:line 29

    /***
     * Extra Function Post Status Parameters
     * Add post status hook parameters
     */
    public static function es_prepare_notification( $post_status, $original_post_status, $post_id )
    {
        /***
         * Remove Post Status Variables
         * Accommodation of transition_post_status passing current and past post status by removing original
         * solution for extracting post status.  Similarly named variables to maintain original functionality.
         */
         //$post_status = isset($_POST['post_status']) ? $_POST['post_status'] : '';
         //$original_post_status = isset($_POST['original_post_status']) ? $_POST['original_post_status'] : '';
    
         ... // Rest of original function
    }

    https://wordpress.org/plugins/email-subscribers/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi mtpultz,

    Thank you for the help. I will update the plugin soon with this code. Thanks

    Hi mtpultz & all,

    1. Scheduled published posts issue has been fixed (From version 1.4 onwards, Notification emails will be triggered for scheduled posts)
    2. New bulk update option for subscribers group in view subscribers admin page.

    Thanks & Regards
    Gopi

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Fix for scheduled published posts’ is closed to new replies.