Title: Email Nofitication based on roles
Last modified: August 31, 2016

---

# Email Nofitication based on roles

 *  [Daniele](https://wordpress.org/support/users/dabesa/)
 * (@dabesa)
 * [10 years ago](https://wordpress.org/support/topic/nofitication-for-all/)
 * Hi guys,
 * I’m using the code here:
    [http://editflow.org/extend/auto-subscribe-user-groups-for-notifications/](http://editflow.org/extend/auto-subscribe-user-groups-for-notifications/)
 * But I’d like to auto subscribe users based on the WordPress role (example: all
   the authors).
    Is it possible?
 * I tried this code with no luck:
 *     ```
       if ( 'pending' == $new_status ) {
       	$usergroup_ids_to_follow = get_users( array( 'role'=>'editor', 'fields' => 'ID' ) );
               $edit_flow->notifications->follow_post_usergroups( $post->ID, $usergroup_ids_to_follow, true );
           }
       ```
   
 * Thanks
 * [https://wordpress.org/plugins/edit-flow/](https://wordpress.org/plugins/edit-flow/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [cojennin](https://wordpress.org/support/users/comradefuzz/)
 * (@comradefuzz)
 * [10 years ago](https://wordpress.org/support/topic/nofitication-for-all/#post-7289349)
 * Hrm, not sure what’s going on.
 * I created the following plugin you can find at this gist: [https://gist.github.com/cojennin/45ac4c91d6319f8f51060a5320d28f86](https://gist.github.com/cojennin/45ac4c91d6319f8f51060a5320d28f86)
 * I installed, then tried the following steps:
    1. As an Admin user, I assigned a user to the “Reporters” usergroup
    2. I logged in as the user I assigned to the “Reporters” usergroup and created 
       a post
    3. I saved the post with status “Pitch”
    4. I set the post’s status to “Pending Review” and then saved the post again
    5. The “Reporters” usergroup was automatically subscribed to the post after I clicked
       save
 * Are those the same steps you took?
 *  Thread Starter [Daniele](https://wordpress.org/support/users/dabesa/)
 * (@dabesa)
 * [10 years ago](https://wordpress.org/support/topic/nofitication-for-all/#post-7289374)
 * Hi Cojennin,
 * When you talk about usergroup, are you referring to WordPress user roles, or 
   to the Edit Flow Groups feature?
 * Our use case is this:
    We have 4 WordPress users with Author role.
 * When a user (any user) set a post to ‘pending review’, we’d like the 4 authors
   to get a notification.
 * Thanks
 *  [cojennin](https://wordpress.org/support/users/comradefuzz/)
 * (@comradefuzz)
 * [10 years ago](https://wordpress.org/support/topic/nofitication-for-all/#post-7289377)
 * Ah, gotcha.
 * Edited the gist: [https://gist.github.com/cojennin/45ac4c91d6319f8f51060a5320d28f86](https://gist.github.com/cojennin/45ac4c91d6319f8f51060a5320d28f86)
 * That should subscribe all users with the WordPress role of ‘editor’ to the post
   being saved as pending. Want to give it a test?
 * Misunderstood what you were trying to do. You were close with your code snippet,
   just need to use `save_post_following_users` instead of `follow_post_usergroups`
   since you want to follow WordPress roles.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Email Nofitication based on roles’ is closed to new replies.

 * ![](https://ps.w.org/edit-flow/assets/icon-256x256.png?rev=3433533)
 * [Edit Flow](https://wordpress.org/plugins/edit-flow/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/edit-flow/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/edit-flow/)
 * [Active Topics](https://wordpress.org/support/plugin/edit-flow/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/edit-flow/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/edit-flow/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [cojennin](https://wordpress.org/support/users/comradefuzz/)
 * Last activity: [10 years ago](https://wordpress.org/support/topic/nofitication-for-all/#post-7289377)
 * Status: not resolved