Last active
May 10, 2016 02:42
-
-
Save cojennin/45ac4c91d6319f8f51060a5320d28f86 to your computer and use it in GitHub Desktop.
plugin to auto-subscribe usergroup based on usergroup user is in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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