• I used some instructions to auto-subscribe user groups found here:
    https://editflow.org/extend/auto-subscribe-user-groups-for-notifications/

    And added the code to my functions with my actual array of user groups I want notified when a post’s $new_status is set to “publish”……but it isn’t working. None of the users in the two user groups in my array are getting the notification when a post is scheduled (future date). I checked the WP Codex, and there is no ‘scheduled’ status, a post is considered to be changed to ‘publish’ when it is scheduled.

    Here is my actual code added to my functions.php:

    // Auto-subscribe user groups to notifications when post is scheduled or published
    function efx_auto_subscribe_usergroup( $new_status, $old_status, $post ) {
        global $edit_flow;
        if ( 'publish' == $new_status ) {
            // You'll need to get term IDs for your user groups and place them as
            // comma-separated values
            $usergroup_ids_to_follow = array(
                 587,679
                );
            $edit_flow->notifications->follow_post_usergroups( $post->ID, $usergroup_ids_to_follow, true );
        } // Return true to send the email notification, false to not send
        return $new_status;
    }
    add_filter( 'ef_notification_status_change', 'efx_auto_subscribe_usergroup', 10, 3 );
    

    What might I be doing wrong? Any help would be gratefully appreciated!

Viewing 1 replies (of 1 total)
  • Thread Starter TrishaM

    (@trisham)

    Well I *thought* I figured it out…..but alas, it still isn’t working.

    I somehow missed this when I was reading about post statuses and status transitions, but there IS a status called ‘future’…..so I changed my code above to use ‘future’ instead of ‘publish’, but it still does not auto-notify the user groups. ??

    You may notice that I’m not using ‘$old_status’ as a variable…..this is because there are times when the old status can be any of the (non-published) statuses….we don’t follow a specific old-to-new path 100% of the time (e.g. we don’t always go from ‘pending review’ to ‘future'(scheduled) – occasionally something may go from draft to published or in-progress to future, etc.

    SO I’m still working on this, any and all suggestions would be appreciated!

Viewing 1 replies (of 1 total)
  • The topic ‘Problem with notification mod’ is closed to new replies.