Skip to content

Instantly share code, notes, and snippets.

@cojennin
Last active May 10, 2016 02:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cojennin/45ac4c91d6319f8f51060a5320d28f86 to your computer and use it in GitHub Desktop.
Save cojennin/45ac4c91d6319f8f51060a5320d28f86 to your computer and use it in GitHub Desktop.
plugin to auto-subscribe usergroup based on usergroup user is in
<?php
/*
Plugin Name: Edit Flow - Auto Subscribe
*/
function efx_auto_subscribe_usergroup( $new_status, $old_status, $post ) {
global $edit_flow;
// When the post is first created, you might want to automatically set
// all of the user's user groups as following the post
if ( 'pending' == $new_status ) {
// Get all of the user groups for this post_author
$users_to_follow = get_users( array( 'role'=> 'editor', 'fields' => 'ID' ) );
$edit_flow->notifications->save_post_following_users( $post->ID, $users_to_follow );
}
// Return true to send the email notification
return $new_status;
}
add_filter( 'ef_notification_status_change', 'efx_auto_subscribe_usergroup', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment