Edit Flow
[resolved] Auto subscribe User (not User Groups) on status change (2 posts)

  1. jimmywags
    Posted 3 years ago #

    I looked over the documentation on the Edit Flow website, and thru the Forum here about how to auto subscribe certain users to a post when the status changes. I saw this: http://editflow.org/extend/auto-subscribe-user-groups-for-notifications/ but it only describes the process for User Groups, not individual users. What is the process for auto subscribing a single (or handful) of users to a post when the status of the post changes?

    In our situation, each contributor is assigned to a specific editor. I'd like each editor to only receive notification when one of their contributors updates their post's status. I could do groups of one and use the filter from the above link, but that seems silly.

    My setup is below. At the end of the two switches, I have one variable, $notify_user, that should be auto-subscribed on a status change. How do I hook that into Edit Flow?

    function efx_auto_subscribe_user( $new_status, $old_status, $post ) {
    	global $edit_flow;
    	// Define editor for each author
    	switch( $post->post_author )
    		case 4: // Andy
    		case 9: // Sarver
    		case 6: // Ryan
    		case 7: // CJ
    			$editor = 5; // Jenn
    		case 5: // Jenn
    		case 10: // Jason
    		case 2: // Jim
    		case 8: // McKenzie
    			$editor = 3; // Jess
    		case 11: // Phil
    		case 12: // Deidre
    		case 3: // Jess
    			$editor = 4; // Andy
    	switch( $new_status )
    		case 'pending-review':
    			$notify_user = $editor;
    		case 'reviewed':
    			$notify_user = $post->post_author;
    		case 'draft':
    		case 'ready-to-publish':
    			$notify_user = 2; // Jim
    	// Return true to send the email notification
    	return true;


  2. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 3 years ago #

    Heh, that's a pretty fun setup.

    To subscribe a user to a post, you can use $edit_flow->notifications->follow_post_user( $post_id, $user_id );

    This will subscribe them before the notification is sent.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Edit Flow
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic