Created
May 10, 2016 02:58
-
-
Save cojennin/fa17eaca6e290f1086cc12ef9da138d3 to your computer and use it in GitHub Desktop.
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 - Autosubscribe Usergroup | |
*/ | |
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 | |
$copy_editors = $edit_flow->user_groups->get_usergroup_by( 'slug', 'ef-usergroup-copy-editors' ); | |
//$usergroup_ids_to_follow = array_map( 'intval', $usergroup_ids_to_follow ); | |
$edit_flow->notifications->save_post_following_usergroups( $post->ID, array((int)$copy_editors->term_id), true ); | |
} | |
// 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
I could use some help with this bit of code....I'm following this example that is similar to the above, but found at:
http://editflow.org/extend/auto-subscribe-user-groups-for-notifications/
I'm using "future" as the $new_status and adding a user group that contain someone I want to be notified only when posts are scheduled.....but it isn't working.....she doesn't get the email and she checks in her spam/junk folder to be sure it isn't there....
Here is my code as modified:
function efx_auto_subscribe_usergroup( $new_status, $old_status, $post ) { global $edit_flow; 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( 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 );
Sorry it looks squished - I've tried twice with pasting my code in between backticks but it still strips out the line breaks.
What might I be doing wrong?