• Resolved wpaholic

    (@wordpressaholic)


    It looks like your plugin might be able to do this though I am still going thru the documentation. I want a simple system where once an author is done, they schedule the post for publishing a few hours in the future. Then, on that scheduling, a notification is sent to an editor. If they get to the post to edit, great. If not, the post goes out as-is at the scheduled time. Is that possible?

    http://wordpress.org/extend/plugins/edit-flow/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor Daniel Bachhuber

    (@danielbachhuber)

    Yep, it’s totally possible. Here’s a code snippet you can follow. Basically, you’ll want to modify it so that the $new_status is ‘future’ and that the usergroup subscribed is the editor user group (with one or more editors)

    Thread Starter wpaholic

    (@wordpressaholic)

    So add this to functions.php then? What part of the code would I copy/paste to get multiple notifications for different statuses? I assume I would change future to ‘Draft’ if I wanted to notify the same group for Draft posts (which I think would happen everytime a new post is made). The ID for my editors seems to be 696.

    /**
     * Auto-subscribe or unsubscribe an Edit Flow user group when a post changes status
     *
     * @see http://editflow.org/extend/auto-subscribe-user-groups-for-notifications/
     *
     * @param string $new_status New post status
     * @param string $old_status Old post status (empty if the post was just created)
     * @param object $post The post being updated
     * @return bool $send_notif Return true to send the email notification, return false to not
     */
    function efx_auto_subscribe_usergroup( $new_status, $old_status, $post ) {
    	global $edit_flow;
    
    	// Choose the slug for whichever status you'd like to auto-subscribe on
    	if ( 'future' == $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(696);
    		$edit_flow->notifications->follow_post_usergroups( $post->ID, $usergroup_ids_to_follow, true );
    	}
    	// Return true to send the email notification
    	return true;
    }
    add_filter( 'ef_notification_status_change', 'efx_auto_subscribe_usergroup', 10, 3 );
    Thread Starter wpaholic

    (@wordpressaholic)

    Oh and is the above “closed” properly? When I added to the bottom of my functions.php, this code started appearing at the top of my dashboard when I’m on editing all posts, or in the appearance/editor while logged in to the WordPress backend.

    Plugin Contributor Daniel Bachhuber

    (@danielbachhuber)

    Looks like you’ve modified it pretty well.

    What part of the code would I copy/paste to get multiple notifications for different statuses?

    You can copy and paste this part:


    // Choose the slug for whichever status you'd like to auto-subscribe on
    if ( 'future' == $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(696);
    $edit_flow->notifications->follow_post_usergroups( $post->ID, $usergroup_ids_to_follow, true );
    }

    Each time the block appears, you can perform an action on a different status.

    Oh and is the above “closed” properly?

    You’ll want to add it before the closing ?>, not after

    Thread Starter wpaholic

    (@wordpressaholic)

    I notice “future” is not a listed status? Is there a list of all possible post statuses/slugs I can compare against somewhere? Can I use something as a catch-all to get all post statuses autosubscribed? Thanks for all your help! This will be really useful.

    Plugin Contributor Daniel Bachhuber

    (@danielbachhuber)

    Is there a list of all possible post statuses/slugs I can compare against somewhere?

    For the most part, the statuses will be those you have defined in your custom statuses. There are also core published statuses like ‘private’, ‘publish’ and ‘future’.

    Can I use something as a catch-all to get all post statuses autosubscribed?

    You’ll just want to drop the if ( 'future' == $new_status ) { statement so that the usergroup is always auto-subscribed.

    Thread Starter wpaholic

    (@wordpressaholic)

    Sorry I’m not a coder so I’m not 100% sure how to do this. Like this? It will know when to update on status changes on posts?

    [Code moderated as per the Forum Rules. The maximum number of lines of code that you can post in these forums is ten lines. Please use the pastebin]

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Plugin: Edit Flow] Notify on scheduled posts’ is closed to new replies.