Support » Plugins and Hacks » Edit Flow » [Resolved] [Plugin: Edit Flow] Retrieve Users in Usergroup

[Resolved] [Plugin: Edit Flow] Retrieve Users in Usergroup

  • I have a plugin for a client that uses Edit Flow and Formidable to accept documents for review and organizes/assigns them using Edit Flow. The plugin intercepts a “submit” command by a particular Formidable form and sets that particular post in the form as “expedited”. That part works, no problem at all. The problem is that the client wants one of their usergroups to be notified when this happens. I’ve been hitting my head with this for a while and cannot come to a solution at all.

    Is there a way to get the users in a user group for me to run a foreach loop to send a batch of emails?


Viewing 9 replies - 1 through 9 (of 9 total)
  • if you would be using standard WP roles, not user groups, you could use those functions (imo self explanatory):

    function get_users_with_role( $role ) {
    $wp_user_search = new WP_User_Search( ”, ”, $role );
    return $wp_user_search->get_results();

    function mail_users_with_role( $role,$subject, $message ) {
    $users = (get_users_with_role($role));
    foreach ($users as $user) {

    for EF roles i do not know, as i do not know what are they using for storing EF group to user – i guess it will be user_meta, so you can just slightly modify the WP_User_Search to search not by role, but using meta (see http://codex.wordpress.org/Class_Reference/WP_User_Query)

    so just for claryfing that second row – you need to find what key is used in ef for storing user group (if it is in usermeta), let’s call it some_ef_role_key and you need to know id of the role, lets call it $ef_role_id:
    $wp_user_search = new WP_User_Query( array(‘meta_key’ => ‘some_ef_role_key’, ‘meta_value’ => $ef_role_id) );

    The usergroup isn’t located in usermeta, I went there first. The usergroup is saved in a separate table with a key of “description” and a value of “{“description”:””,”user_ids”:[“1″,”3″]}” for example. I just need to be able to pull the id’s from that array or use some built in Edit Flow function to get those users.

    Plugin Author Daniel Bachhuber


    There’s a get_usergroups_for_user() method you can use on the $editflow->user_groups object.

    is there any reason why don’t you use built-in tables? this is a typical user meta information

    Plugin Author Daniel Bachhuber


    You can also use get_usergroup_by() to retrieve a given user group, and $users will be a key on the object.

    Plugin Author Daniel Bachhuber


    @thomask we refactored a bit to get it work on WordPress.com VIP, and in that context it’s better to store outside the user meta table. Also, the lookups are more often seeing which users are in a user group, rather than which user groups a user has, so it’s a better lookup.

    Could you explain how to use that, Daniel? I’d greatly appreciate it. A small example of how to pull the $users from the output?

    thank you – please could you look at http://wordpress.org/support/topic/plugin-edit-flow-some-transition_post_status-action?replies=2#post-3248739 and confirm, that your code does not work so that i do not try to find out?

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Resolved] [Plugin: Edit Flow] Retrieve Users in Usergroup’ is closed to new replies.
Skip to toolbar